OCP 1Z0 051 155
来源:互联网 发布:淘宝客经典文案 编辑:程序博客网 时间:2024/06/10 02:02
155. Evaluate the following SQL statement:
SQL> SELECT promo_id, promo_category
FROM promotions
WHERE promo_category = 'Internet' ORDER BY 2 DESC
UNION
SELECT promo_id, promo_category
FROM promotions
WHERE promo_category = 'TV'
UNION
SELECT promo_id, promo_category
FROM promotions
WHERE promo_category ='Radio';
Which statement is true regarding the outcome of the above query?
A. It executes successfully and displays rows in the descending order of PROMO_CATEGORY.
B. It produces an error because positional notation cannot be used in the ORDER BY clause with SET
operators.
C. It executes successfully but ignores the ORDER BY clause because it is not located at the end of the
compound statement.
D. It produces an error because the ORDER BY clause should appear only at the end of a compound
query-that is, with the last SELECT statement.
普通语句 order by 可以用别名,列名,列位置
但当有union minus这些集合操作时就只能用第一个集合的别名,或列位置
且order by 只能放在最后,如果放面前面的集合会报错
Answer: D
SQL> SELECT promo_id, promo_category
FROM promotions
WHERE promo_category = 'Internet' ORDER BY 2 DESC
UNION
SELECT promo_id, promo_category
FROM promotions
WHERE promo_category = 'TV'
UNION
SELECT promo_id, promo_category
FROM promotions
WHERE promo_category ='Radio';
Which statement is true regarding the outcome of the above query?
A. It executes successfully and displays rows in the descending order of PROMO_CATEGORY.
B. It produces an error because positional notation cannot be used in the ORDER BY clause with SET
operators.
C. It executes successfully but ignores the ORDER BY clause because it is not located at the end of the
compound statement.
D. It produces an error because the ORDER BY clause should appear only at the end of a compound
query-that is, with the last SELECT statement.
普通语句 order by 可以用别名,列名,列位置
SQL> select dname,loc from dept order by deptno;DNAME LOC-------------- -------------ACCOUNTING NEW YORKRESEARCH DALLASSALES CHICAGOOPERATIONS BOSTON4 rows selectedSQL> select dname,loc from dept order by 1;DNAME LOC-------------- -------------ACCOUNTING NEW YORKOPERATIONS BOSTONRESEARCH DALLASSALES CHICAGO4 rows selectedSQL> select dname as 部门,loc from dept order by 部门;部门 LOC-------------- -------------ACCOUNTING NEW YORKOPERATIONS BOSTONRESEARCH DALLASSALES CHICAGO4 rows selected
但当有union minus这些集合操作时就只能用第一个集合的别名,或列位置
SQL> select id as col1 from t1 union select no from t2 order by id;select id as col1 from t1 union select no from t2 order by idORA-00904: "ID": invalid identifierSQL> select id as col1 from t1 union select no from t2 order by col1;COL1---- 1 2 34 rows selectedSQL> select id as col1 from t1 union select no from t2 order by 1;COL1---- 1 2 34 rows selected
且order by 只能放在最后,如果放面前面的集合会报错
SQL> select id as col1 from t1 order by 1 union select no from t2;select id as col1 from t1 order by 1 union select no from t2ORA-00933: SQL command not properly ended
Answer: D
0 0
- OCP 1Z0 051 155
- OCP 1Z0 052 155
- OCP 1Z0 053 155
- OCP 1Z0 051 1
- OCP 1Z0 051 2
- OCP 1Z0 051 3
- OCP 1Z0 051 4
- OCP 1Z0 051 5
- OCP 1Z0 051 6
- OCP 1Z0 051 7
- OCP 1Z0 051 8
- OCP 1Z0 051 9
- OCP 1Z0 051 10
- OCP 1Z0 051 11
- OCP 1Z0 051 12
- OCP 1Z0 051 13
- OCP 1Z0 051 14
- OCP 1Z0 051 15
- java中的进制转换
- 黑马程序员_多线程
- Jquery
- android 写行为日志到SD卡 并发处理 异步写入数据到文件不影响界面响应时间
- hdu 4786 Fibonacci Tree
- OCP 1Z0 051 155
- 面向Windows的文件透明加解密解决方案(3)——透明加解密驱动程序一
- leetcode - Populating Next Right Pointers in Each Node
- java基础知识---初始化块、调用顺序
- .NET视频学习总结
- 工厂模式与策略模式之区别
- 解决VC不能添加文件到工程的问题
- linq和lambda表达式
- 连接MySQL 提示错误"未能加载文件或程序集“MySql.Data, Version=5.1.4.0,