不会写 TO_NUMBER
Can't write TO_NUMBER
我将数字保存在 table 中作为字符串,例如
25758313,1
200000000
1418213,04
我知道有 1) 总是没有组分隔符; 2) 如果需要,逗号作为小数点分隔符; 3) 不超过 2 个十进制字符。
尝试使用定义为 to_number(string_val) 的列创建视图,但可以编写正确的表达式。
manual page for TO_NUMBER()
有一个你可以改编的例子:
The 'nlsparam'
argument in this function has the same purpose as it
does in the TO_CHAR
function for number conversions.
SELECT TO_NUMBER('-AusDollars100','L9G999D99',
' NLS_NUMERIC_CHARACTERS = '',.''
NLS_CURRENCY = ''AusDollars''
') "Amount"
FROM DUAL;
可能是这样的:
WITH data AS (
SELECT '25758313,1' AS original_text FROM DUAL
UNION ALL SELECT '200000000' FROM DUAL
UNION ALL SELECT '1418213,04' FROM DUAL
)
SELECT original_text,
TO_NUMBER(original_text, '999999999999D999999999999', 'NLS_NUMERIC_CHARACTERS = '',.''') AS parsed_number
FROM data;
ORIGINAL_T PARSED_NUMBER
---------- -------------
25758313,1 25758313.1
200000000 200000000
1418213,04 1418213.04
我将数字保存在 table 中作为字符串,例如
25758313,1
200000000
1418213,04
我知道有 1) 总是没有组分隔符; 2) 如果需要,逗号作为小数点分隔符; 3) 不超过 2 个十进制字符。
尝试使用定义为 to_number(string_val) 的列创建视图,但可以编写正确的表达式。
manual page for TO_NUMBER()
有一个你可以改编的例子:
The
'nlsparam'
argument in this function has the same purpose as it does in theTO_CHAR
function for number conversions.SELECT TO_NUMBER('-AusDollars100','L9G999D99', ' NLS_NUMERIC_CHARACTERS = '',.'' NLS_CURRENCY = ''AusDollars'' ') "Amount" FROM DUAL;
可能是这样的:
WITH data AS (
SELECT '25758313,1' AS original_text FROM DUAL
UNION ALL SELECT '200000000' FROM DUAL
UNION ALL SELECT '1418213,04' FROM DUAL
)
SELECT original_text,
TO_NUMBER(original_text, '999999999999D999999999999', 'NLS_NUMERIC_CHARACTERS = '',.''') AS parsed_number
FROM data;
ORIGINAL_T PARSED_NUMBER
---------- -------------
25758313,1 25758313.1
200000000 200000000
1418213,04 1418213.04