Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Getting diff values for the same filter criteria using float

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Furor

New User


Joined: 04 Jun 2009
Posts: 30
Location: Bangalore

PostPosted: Wed May 12, 2010 3:10 pm    Post subject: Getting diff values for the same filter criteria using float
Reply with quote

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
View user's profile Send private message

GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Wed May 12, 2010 5:11 pm    Post subject:
Reply with quote

have you tried with SUM(decFLOAT(Y,34)) ?
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed May 12, 2010 9:47 pm    Post subject:
Reply with quote

What about
Code:

FLOAT(SUM(Y))


?

What is your DB2 Version ?
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Wed May 12, 2010 9:57 pm    Post subject: Reply to: Getting diff values for the same filter criteria u
Reply with quote

floating point numbers are approximate,
in general, for approximate numbers the order of operations makes a difference
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Using 'parm' to vary SORTOUT record v... Sysaron DFSORT/ICETOOL 13 Wed Sep 07, 2016 9:24 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us