开发者

Coalesce Function in DB2

开发者 https://www.devze.com 2023-04-08 08:54 出处:网络
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)

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,'&nbsp开发者_如何学编程')

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

0

精彩评论

暂无评论...
验证码 换一张
取 消