Page 1 of 1

DEC function in DB2

PostPosted: Wed Feb 17, 2016 2:29 am
by sikkandhar
Hi All,

I have used DEC function in the query and got a question in that

SELECT CASE WHEN A.COL1 = 'A'
THEN DEC((A.COL2 - A.COL4),18,5)
ELSE A.COL5
END

In the table, COL5 has been defined as DECIMAL (16,2), so it would carry 2 decimals

From the above case statement, if the WHEN condition gets satisfied, then the result should have 5 decimals in the result, and if the ELSE gets satisfied, there should be 2 decimals in the result.
But i get 5 decimals for both the conditions. Am not able to understand why there should be 5 decimals returned for COL5, when it has been defined only with 2 decimals in the table.

Thanks in advance
Sikkandhar