Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 IBEGENER RETURN CODE 12 anilkumar922 All Other Mainframe Topics 5 Wed Dec 13, 2017 11:41 am
No new posts Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts Return a Non Numeric value from REXX Learncoholic CLIST & REXX 3 Fri Sep 01, 2017 8:33 pm
No new posts EXIT or RETURN cvnlynn CLIST & REXX 18 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

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us