on 02-29-2016 7:10 PM
hi everybody,
The problem that I have is that IQ is rounding any arithmetic division, por example if I execute the query:
SELECT 100/123;
It returns 0.
Any division is returning justo 1 or 0.
What is happening? Is there any option to enable (or diseable) to obtain the correct value?
Thank you.!!!
BTW: I'm using this version:
SAP IQ/16.0.0.807/140804/P/sp08.03/Enterprise
This is integer division, so it will return integer. Try select 100.0/123 which is floating point (double) division
Regards
Shashi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So, two things. In your first example you left off the FROM clause. That causes the work to be done in the SA engine, not IQ, so your answers could vary.
Second, you could cast, too, like this:
select convert( double, campo1 ) / convert( double, campo2 ) FROM table_name_here
If double is not precise enough then use numeric or decimal with scale and precision defined.
Mark
Yes, multiply by 1.0 is another way to force decimal division.
select 1.0 * campo1/campo2 from FACT_TABLE;
Eg.
Select 1.0 * 100/123 from iq_dummy ;
Result : 0.8130
By the way, this blog may help
http://scn.sap.com/community/database/blog/2014/12/04/sql-conversion-by-exodus-examples-2
Regards,
Tayeb.
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.