嵌套函数-SQL语言基础

时间:2024-05-15 13:24:55
【文件属性】:

文件名称:嵌套函数-SQL语言基础

文件大小:5.26MB

文件格式:PPT

更新时间:2024-05-15 13:24:55

SQL 基础

嵌套函数 * SQL> SELECT ename, 2 NVL(TO_CHAR(mgr),'No Manager') 3 FROM emp 4 WHERE mgr IS NULL; ENAME NVL(TO_CHAR(MGR),'NOMANAGER') ---------- ----------------------------- KING No Manager * SELECT ename, NVL(TO_CHAR(mgr),'No Manager') FROM emp WHERE mgr IS NULL; Nesting Functions (continued) The slide example displays the head of the company, who has no manager. The evaluation of the SQL statement involves two steps: 1. Evaluate the inner function to convert a number value to a character string. Result1 = TO_CHAR(mgr) 2. Evaluate the outer function to replace the null value with a text string. NVL(Result1, 'No Manager') The entire expression becomes the column heading because no column alias was given. Example Display the date of the next Friday that is six months from the hire date. The resulting date should appear as Friday, March 12th, 1982. Order the results by hire date. Instructor Note Demo: l3nest.sql Purpose: To illustrate nesting of several single row functions. SQL> SELECT TO_CHAR(NEXT_DAY(ADD_MONTHS 2 (hiredate, 6), 'FRIDAY'), 3 'fmDay, Month ddth, YYYY') 4 "Next 6 Month Review" 5 FROM emp 6 ORDER BY hiredate;


网友评论