Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / Informix Topics / October 2006

Tip: Looking for answers? Try searching our database.

how to divide two numbers in a select ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
maik - 26 Oct 2006 15:49 GMT
Hi, I'm new to informix.
I am trying to do a common division like

select   2/1

and I get 0.

Why?
Do I have to do something special here?
Marco Greco - 26 Oct 2006 15:57 GMT
> Hi, I'm new to informix.
> I am trying to do a common division like
[quoted text clipped - 5 lines]
> Why?
> Do I have to do something special here?

your problem is that there is more to being a number than just having digits.
I'd say you are using integers and your dividend is smaller than your divisor.
Cast them to a different datatype, and you may have more luck.

(And next time round, characterize your problem a bit more, before asking for
help)
Signature

Ciao,
Marco
______________________________________________________________________________
Marco Greco /UK /IBM                               Standard disclaimers apply!

Structured Query Scripting Language           http://www.4glworks.com/sqsl.htm
4glworks                                               http://www.4glworks.com
Informix on Linux                        http://www.4glworks.com/ifmxlinux.htm

scottishpoet - 26 Oct 2006 16:01 GMT
> Hi, I'm new to informix.
> I am trying to do a common division like
[quoted text clipped - 5 lines]
> Why?
> Do I have to do something special here?

SELECT 2/1
  FROM systables
       WHERE tabid = 1;

gives me the answer 2.000000000000

which looks ok to me

SELECT 2/1

correctly gives me a syntax error
scottishpoet - 26 Oct 2006 16:03 GMT
> Hi, I'm new to informix.
> I am trying to do a common division like
[quoted text clipped - 5 lines]
> Why?
> Do I have to do something special here?

SELECT 2/1
  FROM systables
       WHERE tabid = 1;

gives me the answer 2.000000000000

which looks ok to me

SELECT 2/1

correctly gives me a syntax error
maik - 26 Oct 2006 16:18 GMT
SELECT 2/1
  FROM systables
       WHERE tabid = 1;

gives me the answer 0

select  trunc(7000 / 6)
  FROM systables
       WHERE tabid = 1;

gives me the answer 1166.66 with is OK, but if I use the real data
fields with those values
i get 116.66

I 'm using an ODBC driver through a DSN .
scottishpoet - 26 Oct 2006 16:53 GMT
what happens if you rn the same query in dbaccess?

if dbaccess gives the expected results it may be time to turn on
sqlidebug or use onstat -g sql to see what your ODBC is sending to the
server

if dbaccess is returning the wrong results it may be time to contact
your support provider

> SELECT 2/1
>    FROM systables
[quoted text clipped - 11 lines]
>
> I 'm using an ODBC driver through a DSN .
Paul Watson - 26 Oct 2006 17:28 GMT
What version are you running and how are you submitting the select

Paul Watson
Tel: +44 1414161772
Mob: +44 7818003457
Web: www.oninit.com

GO FURTHER with DB2
GET THERE FASTER with Informix.
Attend IDUG 2007 San Jose, North America
May 6-10, 2006
Visit http://www.iiug.org/conf for more information.




> -----Original Message-----
> From: maik [mailto:mistermaik@gmail.com]
[quoted text clipped - 17 lines]
>
> I 'm using an ODBC driver through a DSN .
bozon - 26 Oct 2006 18:15 GMT
Does it think that 2/1 is a date somehow? I wonder (2+0)/(1+0) could
probably give you a clue about what is going on.

> SELECT 2/1
>    FROM systables
[quoted text clipped - 11 lines]
>
> I 'm using an ODBC driver through a DSN .
jose luis illera - 28 Oct 2006 01:56 GMT
just testing about an error coming from the informix mail server
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.