天天看點

OCP-1Z0-051 補充題庫 第7題 ORDER BY 子句

一、原題

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

二、題目翻譯

評估下面兩句SQL語句:

關于上面這兩句SQL語句,哪些描述是正确的?

A.這兩個SQL的結果一樣。

B.這兩個SQL都會報錯。

C.這兩個SQL,不需要DESC,因為結果已經預設地被排序了。

D.如果第二個SQL的salary列,加一個列别名,這兩個SQL就會生成相同的結果。

三、題目解析

這兩個SQL語句,生成一樣的結果,order by 2表示,按select語句後顯示的第二列排序,是以兩個SQL語句其實是一樣的。

繼續閱讀