choose threethis
Examine this SQL statement:排序
SELECT cust_id, cus_ last_name "Last Name"three
FROM customersio
WHERE country_id = 10ast
UNIONsed
SELECT cust_id CUST_NO, cust_last_nameselect
FROM customersnio
WHERE country_id = 30總結
Identify three ORDER BY clauses, any one of which can complete the query successfully.sort
A) ORDERBY 2, 1
B) ORDER BY "CUST_NO"
C) ORDER BY 2,cust_id
D) ORDER BY CUST_NO
E) ORDER BY "Last Name"
Answer:ACE
(解析:此題的解析跟下面的解析同樣,答案就是按照解析的總結規律找出來的。)
071-140 題目:
SELECT department_id "DEPT_ID", department_name, 'b' FROM departments
WHERE department_id=90 UNION
SELECT department_id, department_name DEPT_NAME, 'a' FROM departments
WHERE department_id=10
Which two ORDER BY clauses can be used to sort output?
A. ORDER BY DEPT_NAME;
B. ORDER BY DEPT_ID;
C. ORDER BY 'b';
D. ORDER BY 3;
Correct Answer: BD
(解析:經過實驗發現別名必須是用雙引號歸納起來的才能夠用來排序;並且發現取了別名(別名用雙引號歸納)的列的名字也不能用來排序;沒有用雙引號歸納起來的別名的列名能夠用來排序;order by 3,能夠根據顯示的列的順序進行排序。
注意 union 排序的的時候 order by 要寫在語句的最後;發現只能在第一條 select 語句中的列進行排序。)
SQL> select empno "CUST_NO",ename "LAST NAME",'a' FROM emp
2 UNION
3 SELECT EMPNO ,ENAME,'b' FROM emp
4 ORDER BY empno;
ORDER BY empno
*
第 4 行出現錯誤:
ORA-00904: "EMPNO": 標識符無效