设为首页 加入收藏

TOP

ocp1Z0-051141-175题解析(二)
2014-11-24 08:04:39 来源: 作者: 【 】 浏览:8
Tags:ocp1Z0-051141-175 解析
前时间越近

144. View the Exhibitand examine the structure of the PRODUCTS table.

You want to display thecategory with the maximum number of items.

You issue the followingquery:

SQL>SELECTCOUNT(*),prod_category_id

FROM products

GROUP BYprod_category_id

HAVING COUNT(*) =(SELECT MAX(COUNT(*)) FROM products);

What is the outcome

\

A. It executessuccessfully and gives the correct output.

B. It executessuccessfully but does not give the correct output.

C. It generates an errorbecause the subquery does not have a GROUP BY clause.

D. It generates an errorbecause = is not valid and should be replaced by the IN operator.

Answer: C

解析:

子查询用在group by 后面是错误的

145. View the Exhibitand examine the structure of the CUSTOMERS table.

You issue the followingSQL statement on the CUSTOMERS table to display the customers who are in the

same country ascustomers with the last name 'KING' and whose credit limit is less than themaximum

credit limit incountries that have customers with the last name 'KING':

SQL> SELECTcust_id,cust_last_name

FROM customers

WHERE country_idIN(SELECT country_id

FROM customers

WHERE cust_last_name='King')

AND cust_credit_limit< (SELECT MAX(cust_credit_limit)

FROM customers

WHERE country_idIN(SELECT country_id

FROM customers

WHEREcust_last_name='King'));

Which statement is trueregarding the outcome of the above query

\

A. It executes and showsthe required result.

B. It produces an errorand the < operator should be replaced by < ALL to get the requiredoutput.

C. It produces an errorand the < operator should be replaced by < ANY to get the requiredoutput.

D. It produces an errorand the IN operator should be replaced by = in the WHERE clause of the main

query to get therequired output.

Answer: A

解析:

题意:

display the customerswho are in the

same country as customerswith the last name 'KING' and whose credit limit isless than the maximum

credit limit incountries that have customers with the last name 'KING':

customers withthe last name 'KING'

WHERE country_idIN(SELECT country_id

FROM customers

WHERE cust_last_name='King')

找到所有cust_last_name为king的

whose creditlimit is less than the maximum

credit limitin countries that have customers with the last name 'KING':

cust_credit_limit小于last name 为king中最大的cust _credit_limit

cust_credit_limit <(SELECT MAX(cust_credit_limit)

FROM customers

WHERE country_idIN(SELECT country_id

FROM customers

WHERE cust_last_name='King'));

146. eva luate thefollowing SQL statement:

SQL> SELECT cust_id,cust_last_name

FROM customers

WHERE cust_credit_limitIN

(selectcust_credit_limit

FROM customers

WHERE cust_city='Singapore');

Which statement is trueregarding the above query if one of the values generated by the subquery is

NULL

A. It produces an error.

B. It executes butreturns no rows.

C. It generates outputfor NULL as well as the other values produced by the subquery.

D. It ignores the NULLvalue and generates output for the other values produced by the subquery.

Answer: C

解析:

In 如果子查询中得到部分行为空,则只会返回不为空的行,测试:

scott@ORCL>select *from emp where sal<2000;

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

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

7369 SMITH CLERK 7902 17-12-80 968 20

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

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

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

7788 SCOTT ANALYST 7566 19-04-87 1850 20

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

7876 ADAMS CLERK 7788 23-05-87 1100 20

7900 JAMES CLERK 7698 03-12-81 950 30

7934 MILLER CLERK 7782 23-01-82 1430 10

已选择9行。

scott@ORCL>select *from emp where comm in (select comm from em

首页 上一页 1 2 3 4 5 6 7 下一页 尾页 2/10/10
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇oracle报错 下一篇ORA-01078与LRM-00109报错解决

评论

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

·C 内存管理 | 菜鸟教 (2025-12-26 20:20:37)
·如何在 C 语言函数中 (2025-12-26 20:20:34)
·国际音标 [ç] (2025-12-26 20:20:31)
·微服务 Spring Boot (2025-12-26 18:20:10)
·如何调整 Redis 内存 (2025-12-26 18:20:07)