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
 

 

DB2 SQL AVG function does not return decimal

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

New User


Joined: 30 Aug 2005
Posts: 22

PostPosted: Fri Nov 19, 2010 12:43 pm    Post subject: DB2 SQL AVG function does not return decimal
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    Post subject:
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    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 EXIT or RETURN cvnlynn CLIST & REXX 5 Wed Jul 19, 2017 2:50 am
No new posts What is the Extract Function in JCL dharmaraok JCL & VSAM 3 Wed Jun 14, 2017 9:12 am
No new posts QUESTION: RETURN CHANNEL pahiker CA Products 21 Thu Apr 20, 2017 12:31 am
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Joinkeys with decimal scdinesh DFSORT/ICETOOL 3 Fri Feb 10, 2017 4:46 am


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