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值等,可以帮助用户更灵活地处理和显示数据。