View previous topic :: View next topic
|
Author |
Message |
Furor
New User
Joined: 04 Jun 2009 Posts: 30 Location: Bangalore
|
|
|
|
I was in the process of optimizing a query, for that i had to negate a column so that the index doesn't participate in the execution.
Previous Query:
Code: |
SELECT COUNT(*),
SUM(X),
SUM(FLOAT(Y)),
SUM(Z)
FROM T1 A , T2 B
WHERE A.HIST = 'H'
AND B.CD = 'ABC'
AND A.ID = B.ID
AND A.DT = '04/26/2010'; |
Results:
Code: |
38616 3109401.380000 -0.1518154911700070E+09 4152744718.859000 |
New Query :
Code: |
SELECT COUNT(*),
SUM(X),
SUM(FLOAT(Y)),
SUM(Z)
FROM T1 A , T2 B
WHERE (A.HIST = 'H' OR 0=1)
AND B.CD = 'ABC'
AND A.ID = B.ID
AND A.DT = '04/26/2010'; |
Results:
Code: |
38616 3109401.380000 -0.1518154911700006E+09 4152744718.859000 |
I am unable to identify why there is differnce in the value of SUM(FLOAT(Y)),
Code: |
-0.1518154911700070E+09
-0.1518154911700006E+09 |
|
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
have you tried with SUM(decFLOAT(Y,34)) ? |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
What about
?
What is your DB2 Version ? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
floating point numbers are approximate,
in general, for approximate numbers the order of operations makes a difference |
|
Back to top |
|
|
|