149. View the Exhibits and examine the structures of the COSTS and PROMOTIONS tables.
Evaluate the following SQL statement:
SQL> SELECT prod_id FROM costs
WHERE promo_id IN (SELECT promo_id FROM promotions
WHERE promo_cost < ALL
(SELECT MAX(promo_cost) FROM promotions
GROUP BY (promo_end_date-
promo_begin_date)));
What would be the outcome of the above SQL statement?
A. It displays prod IDs in the promo with the lowest cost.
B. It displays prod IDs in the promos with the lowest cost in the same time interval.
C. It displays prod IDs in the promos with the highest cost in the same time interval.
D. It displays prod IDs in the promos with cost less than the highest cost in the same time interval.
Answer: D
答案解析:
1、首先查询出promo_end_date- promo_begin_date期间promo_cost的最大值

本文深入解析一个SQL查询语句,该语句利用嵌套子查询来筛选特定条件下的产品ID。通过展示具体的SQL语句执行过程和结果,帮助读者理解如何在SQL查询中运用复杂的条件过滤机制。

334

被折叠的 条评论
为什么被折叠?



