一、原题
二、题目翻译
三、题目解析
Evaluate these two SQL statements:
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY salary DESC;
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC;
What is true about them?
A. The two statements produce identical results.
B. The second statement returns a syntax error.
C. There is no need to specify DESC because the results are sorted in descending order by
default.
D. The two statements can be made to produce identical results by adding a column alias for the
salary column in the second SQL statement.
答案: A
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY salary DESC;
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC;
What is true about them?
A. The two statements produce identical results.
B. The second statement returns a syntax error.
C. There is no need to specify DESC because the results are sorted in descending order by
default.
D. The two statements can be made to produce identical results by adding a column alias for the
salary column in the second SQL statement.
答案: A
二、题目翻译
评估下面两句SQL语句:
关于上面这两句SQL语句,哪些描述是正确的?
A.这两个SQL的结果一样。
B.这两个SQL都会报错。
C.这两个SQL,不需要DESC,因为结果已经默认地被排序了。
D.如果第二个SQL的salary列,加一个列别名,这两个SQL就会生成相同的结果。
关于上面这两句SQL语句,哪些描述是正确的?
A.这两个SQL的结果一样。
B.这两个SQL都会报错。
C.这两个SQL,不需要DESC,因为结果已经默认地被排序了。
D.如果第二个SQL的salary列,加一个列别名,这两个SQL就会生成相同的结果。
三、题目解析
这两个SQL语句,生成一样的结果,order by 2表示,按select语句后显示的第二列排序,所以两个SQL语句其实是一样的。