Which query would give you the required output?

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?

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’);



Leave a Reply 10

Your email address will not be published. Required fields are marked *


khanh

khanh

Why is A wrong? Please explain for me

Anand Aili

Anand Aili

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

LUIGUS

LUIGUS

YES, WHY OPTION A IS WRONG?

Anand Aili

Anand Aili

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

Sayed

Sayed

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.

Prince jain

Prince jain

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.

Charfi Walid

Charfi Walid

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().

Charfi wa

Charfi wa

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”.

Alvin2201

Alvin2201

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.

Bruno Iamada

Bruno Iamada

A and C, the two it’s correct !