Joined: 18 May 2005 Posts: 108 Topics: 31 Location: USA
Posted: Wed Aug 10, 2005 1:30 pm Post subject: Truncate function
Is there any DB2 function to truncate the decimal values up to 2 or so?
I have the below query which I need the value till 2nd precision in decimal value.
Code:
SELECT COUNT1,COUNT2,COUNT3,COUNT4,COUNT5,COUNT6,COUNT7,
(DECIMAL((COUNT2*100),10,3)/(COUNT2+COUNT3+COUNT4+COUNT5+COUNT6+COUNT7))
AS PERCENTAGE
FROM IDTOUT01.ITOUREPORT WHERE SESSIONID='20050810132342243129'
Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
Posted: Wed Aug 10, 2005 2:19 pm Post subject:
Schintala,
Please provide us with the sample input and desired output. I think you need to use the CAST function. btw are you able to solve the problem posted here?
I need the data in percentage column as 24.67, 11.36, 24.15, 11.36 etc.
My query like this.
Code:
SELECT COUNT1,COUNT2,COUNT3,COUNT4,COUNT5,COUNT6,COUNT7, TRUNCATE((DECIMAL((COUNT2*100),10)/(COUNT2+COUNT3+COUNT4+COUNT5+COUNT6
+COUNT7)),2)
AS PERCENTAGE
FROM IDTOUT01.ITOUREPORT;
Schintala,
Cogito solution should be ok without the ROUND option,
SELECT DECIMAL((1234.5694),8,2)
, DECIMAL(ROUND(1234.5694,2),8,2)
FROM SYSIBM.SYSDUMMY1 ;
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum