如何在oracle中显示如下值:
99.99为99.9900, 99.9为99.9000, 9.99为9.9900, 99为99.0000
所有案件都应该得到满足.. 请帮忙......
答案 0 :(得分:2)
使用格式字符0
:
SQL> SELECT x, to_char(x, '99.0000')
2 FROM (SELECT 99.99 x FROM dual
3 UNION ALL SELECT 99.9 FROM dual
4 UNION ALL SELECT 9.99 FROM dual
5 UNION ALL SELECT 99 FROM dual);
X TO_CHAR(X,'99.0000')
---------- --------------------
99,99 99.9900
99,9 99.9000
9,99 9.9900
99 99.0000
您可以在documentation中找到所有格式选项。
答案 1 :(得分:0)
使用 TO_CHAR 功能,格式参数为:
select to_char(99.99, '99.9999') from dual;