设为首页 加入收藏

TOP

ocp1Z0-051106-140题解析(十)
2014-11-24 08:07:01 来源: 作者: 【 】 浏览:25
Tags:ocp1Z0-051106-140 解析
e followingquery to display product name and the number of times the product has been

sold:

SQL>SELECTp.prod_name, i.item_cnt

FROM (SELECT prod_id,COUNT(*) item_cnt

FROM sales

GROUP BY prod_id) iRIGHT OUTER JOIN products p

ON i.prod_id =p.prod_id;

What happens when theabove statement is executed

A. The statementexecutes successfully and produces the required output.

B. The statementproduces an error because ITEM_CNT cannot be displayed in the outer query.

C. The statement producesan error because a subquery in the FROM clause and outer-joins cannot be

used together.

D. The statementproduces an error because the GROUP BY clause cannot be used in a subquery inthe

FROM clause.

Answer: A

解析:
将 SELECT prod_id, COUNT(*) item_cnt

FROM sales

GROUP BY prod_id

的查询结果作为一张表和product表右外连接 ,可以得到product中每个产品的销售次数

138. Which statement istrue regarding subqueries

A. The LIKE operatorcannot be used with single- row subqueries.

B. The NOT IN operatoris equivalent to IS NULL with single- row subqueries.

C. =ANY and =ALLoperators have the same functionality in multiple- row subqueries.

D. The NOT operator canbe used with IN, ANY, and ALL operators in multiple- row subqueries.

Answer: D

解析:

A选项,测试: scott@ORCL>select * from emp where ename like (selectename from emp where empno=7788);

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ------------------- ---------- -------- ---------- ---------- ----------

7788 SCOTT ANALYST 7566 19-04-87 1850 20

B选项,不相等,not in 如果不处理子查询中的空值,就会全部返回为空

C选项,功能不一样,any表示已任意一个,all表示全部

139. Which threestatements are true about multiple-row subqueries (Choose three.)

A. They can contain asubquery within a subquery.

B. They can returnmultiple columns as well as rows.

C. They cannot contain asubquery within a subquery.

D. They can return onlyone column but multiple rows.

E. They can containgroup functions and GROUP BY and HAVING clauses.

F. They can containgroup functions and the GROUP BY clause, but not the HAVING clause.

Answer: ABE

解析:

C选项,子查询可以嵌套

应用官方文档:

A subquery can containanother subquery. Oracle Database imposes no limit on the

number of subquerylevels in the FROM clause of the top-level query. You can nest up

to 255 levels ofsubqueries in the WHERE clause

D选项,可以返回多列多行

F选项,测试:

scott@ORCL>select *from emp where job in(select job from emp group by job having job like 'S%');

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ------------------- ---------- -------- ---------- ---------- ----------

7844 TURNER SALESMAN 7698 08-09-81 1500 0 30

7654 MARTIN SALESMAN 7698 28-09-81 1250 1400 30

7521 WARD SALESMAN 7698 22-02-81 1250 500 30

7499 ALLEN SALESMAN 7698 20-02-81 1600 160 30

140. Examine thestructure of the PRODUCTS table:

name Null Type

PROD_ID NOT NULLNUMBER(4)

PROD_NAME VARCHAR2(20)

PROD_STATUS VARCHAR2(6)

QTY_IN_HAND NUMBER(8,2)

UNIT_PRICE NUMBER(10,2)

You want to display thenames of the products that have the highest total value for UNIT_PRICE *

QTY_IN_HAND.

Which SQL statementgives the required output

A. SELECT prod_name

FROM products

WHERE (unit_price *qty_in_hand) = (SELECT MAX(unit_price * qty_in_hand)

FROM products);

B. SELECT prod_name

FROM products

WHERE (unit_price *qty_in_hand) = (SELECT MAX(unit_price * qty_in_hand)

FROM products

GROUP BY prod_name);

C. SELECT prod_name

FROM products

GROUP BY prod_name

HAVING MAX(unit_price *qty_in_hand) = (SELECT MAX(unit_price * qty_in_hand)

FROM products

GROUP BY pr

首页 上一页 7 8 9 10 下一页 尾页 10/10/10
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇DBA手记:DBA诊断利器 - Event 100.. 下一篇Oracle 11g New 使用数据恢复指导

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·上海启源芯动力的福 (2025-12-26 20:50:23)
·为什么动力电池安全 (2025-12-26 20:50:20)
·动力电池是怎么造出 (2025-12-26 20:50:18)
·C 内存管理 | 菜鸟教 (2025-12-26 20:20:37)
·如何在 C 语言函数中 (2025-12-26 20:20:34)