分类: Oracle
2015-03-20 00:02:41
SQL> SELECT TO_CHAR(1890.55,'$0G000D00') FROM DUAL;
TO_CHAR(18
----------
$1,890.55
B:
SQL> SELECT TO_CHAR(1890.55,'$9,999V99') FROM DUAL;
TO_CHAR(1
---------
$1,89055
C:
SQL> SELECT TO_CHAR(1890.55,'$99,999D99') FROM DUAL;
SELECT TO_CHAR(1890.55,'$99,999D99') FROM DUAL
*
ERROR at line 1:
ORA-01481: invalid number format model
D:
SQL> SELECT TO_CHAR(1890.55,'$99G999D00') FROM DUAL;
TO_CHAR(189
-----------
$1,890.55
E:
SQL> SELECT TO_CHAR(1890.55,'$99G999D99') FROM DUAL;
TO_CHAR(189
-----------
$1,890.55
G表示分组分隔符group
D表示小数点decimal point
V表示移动N位(小数点),乘以10的n次方后面跟几位就是几次方。
","和G或者D不能同时出现,如果把C答案的D改成“.”,也正确
SQL> SELECT TO_CHAR(1890.55,'$99,999.99') FROM DUAL;
TO_CHAR(189
-----------
$1,890.55
总之,字符和字母不能同时出现。