I am using IBM DB2. I have a query which gives the output as:
NAME / AMOUNT
CST / -
VAT / 1400
ST / -
I am trying to write a coalesce function for AMOUNT. The datatype of AMOUNT is decimal(10,2)
COALESCE(AMOUNT,' 开发者_如何学编程')
The purpose of me doing is, I want a space if the AMOUNT is null, but all I get is an error like "incompatible argument".
How can I achieve a space? Please help!
The problem is you are saying this...
If amount is not NULL, display a decimal value, but if it is, display a character value instead. Try this
COALESCE(CAST(AMOUNT as VARCHAR(20)),' ')
Should solve your problem
精彩评论