开发者

Coalesce Function in DB2

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜