【问题标题】:how to get rid of decimal points in netezza如何去掉netezza中的小数点
【发布时间】:2013-09-02 16:27:47
【问题描述】:

你好,我有一个奇怪的要求

如果金额值为 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;

当我写为 select to_char(amount,99) from _v_dual; 但在 case 语句中不起作用我在 to-char 中收到无效格式等错误...

我完全被困在这里,非常感谢任何帮助。

【问题讨论】:

    标签: sql netezza


    【解决方案1】:

    这适用于我的 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;
    

    【讨论】:

      【解决方案2】:

      您是否尝试过在格式字符串周围加上单引号?

      select to_char(amount,'99')

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-03-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多