View the Exhibit and examine the structure of the PROMOTIONS table.
You have to generate a report that displays the promo name and start date for all promos that started after the last promo in the ‘INTERNET’ category.
Which query would give you the required output?
A.
SELECT promo_name, promo_begin_date FROM promotions
WHERE promo_begin_date > ALL (SELECT MAX(promo_begin_date) FROM promotions )AND
promo_category = ‘INTERNET’;
B.
SELECT promo_name, promo_begin_date FROM promotions
WHERE promo_begin_date IN (SELECT promo_begin_date
FROM promotions
WHERE promo_category=’INTERNET’);
C.
SELECT promo_name, promo_begin_date FROM promotions
WHERE promo_begin_date > ALL (SELECT promo_begin_date
FROM promotions
WHERE promo_category = ‘INTERNET’);
D.
SELECT promo_name, promo_begin_date FROM promotions
WHERE promo_begin_date > ANY (SELECT promo_begin_date
FROM promotions
WHERE promo_category = ‘INTERNET’);
Why is A wrong? Please explain for me
Subquery returns all category max promo_begin_date not only INTERNET, so last rekeased INTERNET promo’s begin date never greater than most recent released promo which is returned by above query
YES, WHY OPTION A IS WRONG?
Subquery returns all category max promo_begin_date not only INTERNET, so last rekeased INTERNET promo’s begin date never greater than most recent released promo which is returned by above query
There is nothing wrong with option ‘A’. However, ‘C’ is the best. Because ‘>ALL’ returns ‘more than the maximum’ values of promo_begin_date of category INTERNET. So, we don’t need to use a separate MAX(promo_begin_date)function again.
Option A is not correct.
Because ‘(SELECT MAX(promo_begin_date) FROM promotions )’does not have where clause to filter promo category. Its means MAX(promo_begin_date)will return date may or may not be belong to INTERNET category.
A is wrong Because when we make max() in the subquery we don t need to use the all with it because we will have 1 result with the fonction max().
And other think is that internet categorie condition should be in the subquery if u see the question it says “after the last promo of internet categorie”.
And with query A. you have no error but you end with no rows selected cause no category can have a promo_begin_date that is more than the maximum promo_begin_date of all categories.
A and C, the two it’s correct !