IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DB2 SQL AVG function does not return decimal


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
hnharish

New User


Joined: 30 Aug 2005
Posts: 23

PostPosted: Fri Nov 19, 2010 12:43 pm
Reply with quote

Hi All,

I have written a DB2 sql query to calculate the average value of a column but the issue is the column is not returning Decimal value ex: if the avetrage value is 12.567 its returning the value as 12 i need atleast 2 decimal places to be shown ie. 12.56. Could you pls help me resolving this issue. Thanks in Advance.

Regards,
Harish
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Fri Nov 19, 2010 1:22 pm
Reply with quote

the original column on which the average is calculated is probably integer.
try avg(dec(Col,10,2)) or avg(Col * 1.00) . Both will return you a decimal
if you want only 2 pos after the comma : dec(avg(Col * 1.00),10,2)
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts FUNCTION ADD-DURATION COBOL Programming 11
No new posts SFTP Return Codes TSO/ISPF 2
No new posts purge jobs with return code 0 and ret... JCL & VSAM 6
No new posts Help required to reset decimal points... DFSORT/ICETOOL 10
No new posts Unable to interpret a hex value to De... COBOL Programming 7
Search our Forums:


Back to Top