Skip to main contentSkip to solution

For the following table:

IDNameCategoryPriceQuantitySupplierDate
301IphoneElectronics8000025Apple Inc.2022-06-10
302SamsungElectronics6000040Samsung Elec.2022-05-15
303NikeFootwear1200050Nike2022-07-01
304DellElectronics9000010Dell2022-03-20
305PumaFootwear800060Puma2022-04-05

What will be the sequence of steps from the following to retrieve the products after May 2022?

(A) Use the WHERE clause to filter rows with Date>'2022-05-31'

(B) Select columns Name, Category and Date

(C) Write the SELECT query

(D) Execute the query

Solution

✅ Correct Option: 4

The query is built in the order it is written: start the SELECT statement (C), choose the columns Name, Category and Date (B), add the WHERE clause with Date > '2022-05-31' (A), then execute it (D).

SELECT Name, Category, Date FROM products WHERE Date>’2022-05-31’;\text{SELECT Name, Category, Date FROM products WHERE Date} > \text{'2022-05-31';}

Only Nike (2022-07-01) satisfies this condition.


Options 1, 2 and 3: choosing columns or adding a filter before writing the SELECT query is illogical, since the columns and WHERE clause are parts of the SELECT query. Option 3 also executes before the query is written.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question