ocp-047-66

66. Which two statements are true regarding multiple-row subque ries? (Choose 
two.) 
A. They can contain group functions. 
B. They always contain a subquery within a subquery. 
C. They use the < ALL operator to imply less than the maximum. 
D. They can be used to retrieve multiple rows from a single table only. 
E. They should not be used with the NOT IN operator in the main query if NULL 
is likely to be a part of the result of the subquery. 
Answer: AE 
SQL> select dest,revenue from test where revenue in ( 
    select 4000 from test union  select null from dual); 
DEST          REVENUE 
---------- ---------- 
wenzhou          4000 
SQL> select dest,revenue 
  from test where revenue not in ( 
select 4000 from test union  select null from dual); 
未选定行 
SQL> select dest,revenue 
    from test where revenue not in (select null from dual); 
未选定行 

可以结论:只要子查询里有空值,在主查询就不能用not in,因为不能返回任何值。


ingle-row and multiple-row subqueries
Subqueries that can return only one or zero rows to the outer statement are called single-row subqueries. Single-row subqueries are subqueries used with a comparison operator in a WHERE, or HAVING clause.
Subqueries that can return more than one row (but only one column) to the outer statement are called multiple-row subqueries. Multiple-row subqueries are subqueries used with an IN, ANY, or ALL clause.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值