嗨,我有一个奇怪的要求
如果金额值是0.00,我需要将其显示为0,如果是23.12之类的其他值,则需要使用小数点并显示为23.12。在netezza中尝试了下面的代码,但不起作用
select
case when amount=0.00 then 0
else amount
end;
select case when amount=0.00 then to_char(amount,99)
else to_char(amount,999999.99)
end;当我写成来自_v_dual的select to_char(amount,99)时,它们可以工作;但在case语句中,我得到错误,如to-char中的无效格式时,它们不能工作...
我完全被困在这里,任何帮助都非常感谢。
发布于 2013-09-11 17:37:58
这对我的Netezza数据库很有效。
select to_char(0.00,99) from _v_dual;
select
case when amount=0.00 then 0
else amount
end
from
(select 0.00 as amount) a;发布于 2013-09-03 22:22:32
您有没有尝试过在格式字符串两边加上单引号?
select to_char(amount,'99')
https://stackoverflow.com/questions/18577416
复制相似问题