您的位置:首页 > 产品设计 > UI/UE

OCP 1Z0 051 QUESTION NO: 7

2014-06-02 17:05 363 查看
QUESTION NO: 7

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.

1 order by 默认升序

2 order by 后可以用列位置、列名、别名

TEST > show user
User is "test"

TEST > create table EMPLOYEES as select * from hr.EMPLOYEES where rownum <=5;
Table created

TEST >
TEST > SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY salary DESC;
LAST_NAME                     SALARY HIRE_DATE
------------------------- ---------- -----------
Hartstein                   13000.00 2004-02-17
Fay                          6000.00 2005-08-17
Whalen                       4400.00 2003-09-17
OConnell                     2600.00 2007-06-21
Grant                        2600.00 2008-01-13
5 rows selected
TEST > SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC;
LAST_NAME                     SALARY HIRE_DATE
------------------------- ---------- -----------
Hartstein                   13000.00 2004-02-17
Fay                          6000.00 2005-08-17
Whalen                       4400.00 2003-09-17
OConnell                     2600.00 2007-06-21
Grant                        2600.00 2008-01-13
5 rows selected


Answer: A
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: