142. View the Exhibit and examine the structure of the PRODUCTS table.
Evaluate the following query:
SQL> SELECT prod_name
FROM products
WHERE prod_id IN (SELECT prod_id FROM products
WHERE prod_list_price =
(SELECT MAX(prod_list_price)FROM products
WHERE prod_list_price <
(SELECT MAX(prod_list_price)FROM products)));
What would be the outcome of executing the above SQL statement?
A. It produces an error.
B. It shows the names of all products in the table.
C. It shows the names of products whose list price is the second highest in the table.
D. It shows the names of all products whose list price is less than the maximum list price.
该语句先取出MAX(prod_list_price)
然后取出<MAX(prod_list_price)的数据
在此范围内再次找到MAX(prod_list_price)
也就是第二大
SQL> SELECT prod_name
2 FROM sh.products
3 WHERE prod_id IN
4 (SELECT prod_id
5 FROM sh.products
6 WHERE prod_list_price =
7 (SELECT MAX(prod_list_price)
8 FROM sh.products
9 WHERE prod_list_price <
10 (SELECT MAX(prod_list_price) FROM sh.products)));
PROD_NAME
--------------------------------------------------
Mini DV Camcorder with 3.5" Swivel LCD
1 row selected
SQL> SELECT *
2 FROM (SELECT prod_id, prod_name, prod_list_price
3 FROM sh.products
4 ORDER BY 3 DESC)
5 WHERE rownum <= 3;
PROD_ID PROD_NAME PROD_LIST_PRICE
------- -------------------------------------------------- ---------------
18 Envoy Ambassador 1299.99
17 Mini DV Camcorder with 3.5" Swivel LCD 1099.99
14 17" LCD w/built-in HDTV Tuner 999.99
3 rows selected
Answer: C