Evaluate the following SQL statement:
SQL> SELECT cust_id, cust_last_name
FROM customers
WHERE cust_credit_limit IN
(select cust_credit_limit
FROM customers
WHERE cust_city =’Singapore’);
Which statement is true regarding the above query if one of the values generated by the subquery
is NULL?
A.
It produces an error.
B.
It executes but returns no rows.
C.
It generates output for NULL as well as the other values produced by the subquery.
D.
It ignores the NULL value and generates output for the other values produced by the subquery.
For I D is correct.
When you use IN, you’re telling SQL to take a value and compare it against every value or set of values in a list using =. If any NULL values exist, a row will not be returned–even if both values are NULL.
hwfurlan, you are right, D is correct.
right D is correct
the correct answer is D
select employee_id,last_name,commission_pct, department_id from employees
where commission_pct in (select commission_pct
from employees where department_id in (’50’,’80’))
In this query it ignores all Null values which has department_id of 50.
if there is one result and is null then no rows selected. if there are more results then will ignore null and generate
B tested – result will be no rows selected. no others result will be diplayed… in where clause you have =… so 1 result = is null => no rows selected
SELECT customer_id, cust_last_name
FROM customers
WHERE credit_limit IN
(select credit_limit
FROM customers
WHERE income_level =’255566555′);
no rows selected
this for 1 result !!!!
D is the answare !!!