oracle查询不显示小数点前的0
时间:2021-07-01 10:21:17
帮助过:8人阅读
TO_CHAR(NUM,‘999999999.9999999
.421240000
.421246543
65432.421243240
4.621240000
SQL> select to_char(num) from ml_test;
TO_CHAR(NUM)
.42124
.4212465434
65432.42124324
4.62124
SQL> select to_char(0.99) from dual;
TO_CHAR(0.99)
.99
--4.怎么解决,解决方案如下
(1)
[sql] view plaincopy
- SQL> select to_nmber(to_char(0.99)) from dual;
-
- TO_NUMBER(TO_CHAR(0.99))
- 0.99
-
- SQL> select to_char(num,‘fm999999990.999999999‘) from ml_test;
-
- TO_CHAR(NUM,‘FM999999990.99999
- 0.42124
- 0.421246543
- 65432.42124324
- 4.62124
(2)使用case when 或 decode函数,取第一位是否为".", 补0 ,就ok了
[sql] view plaincopy
- SQL> select to_char(num,‘999999999.999999999‘) from ml_test;
-
- TO_CHAR(NUM,‘999999999.9999999
- .421240000
- .421246543
- 65432.421243240
- 4.621240000
-
- SQL> select to_char(num) from ml_test;
-
- TO_CHAR(NUM)
- .42124
- .4212465434
- 65432.42124324
- 4.62124
-
- SQL> select to_char(0.99) from dual;
-
- TO_CHAR(0.99)
- .99
-
oracle查询不显示小数点前的0
标签: