SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD') AS formatted_date
FROM dual;
SELECT TO_CHAR(123456.789, 'FM$99,999.00') AS formatted_number
FROM dual;
SELECT TO_CHAR(SYSDATE, 'Day, DD Month YYYY') AS custom_date_format
FROM dual;
SELECT TO_CHAR(SYSDATE, 'DD Month YYYY', 'NLS_DATE_LANGUAGE=FRENCH') AS french_date
FROM dual;
SELECT TO_CHAR(salary, '$99,999.00') AS formatted_salary
FROM employees;
總的來說,to_char函數在SQL中的高級應用包括日期、數字格式化、自定義格式、多語言支持以及處理NULL值等,可以幫助用戶更靈活地處理和顯示數據。