TO_NUMBER函數(shù)是Oracle SQL中用于將字符型數(shù)據(jù)轉(zhuǎn)換為數(shù)字型數(shù)據(jù)的函數(shù)。下面是TO_NUMBER函數(shù)的一些靈活運(yùn)用技巧:
SELECT TO_NUMBER('12345') FROM dual;
SELECT TO_NUMBER('1,234.56', '999G999D99') FROM dual;
SELECT TO_NUMBER('$1,234.56', 'L999G999D99') FROM dual;
SELECT TO_NUMBER(NULLIF('12345', ''), '99999') FROM dual;
SELECT TO_NUMBER('1.23456E+4', '9.99999EEEE') FROM dual;
SELECT TO_NUMBER('123.456', '999.999') FROM dual;
SELECT CASE WHEN TO_NUMBER('12345') > 10000 THEN '大于10000' ELSE '小于等于10000' END FROM dual;
這些技巧可以幫助你更靈活地使用TO_NUMBER函數(shù)在Oracle SQL中進(jìn)行數(shù)據(jù)類(lèi)型轉(zhuǎn)換。