nerdexam
Snowflake

SOL-C01 · Question #86

You have a table named 'CUSTOMER ORDERS with columns customer id', order date' , and 'order amount'. You want to retrieve the top 5 customers who placed orders on a specific date ('2023-01-15') based

The correct answer is A. SELECT customer_id, AS total_amount FROM CUSTOMER_ORDERS WHERE order_date =. Option A is correct because it combines all required elements: a WHERE order_date = '2023-01-15' clause to filter by the specific date, SUM(order_amount) AS total_amount to aggregate each customer's total, GROUP BY customer_id to collapse rows per customer, ORDER BY total_amount

Querying and Performance

Question

You have a table named 'CUSTOMER ORDERS with columns customer id', order date' , and 'order amount'. You want to retrieve the top 5 customers who placed orders on a specific date ('2023-01-15') based on the total order amount. Which SQL query will achieve this?

Options

  • ASELECT customer_id, AS total_amount FROM CUSTOMER_ORDERS WHERE order_date =
  • BSELECT customer_id, AS total_amount FROM CUSTOMER_ORDERS GROUP BY customer_id
  • CSELECT customer_id, AS total_amount FROM CUSTOMER_ORDERS WHERE order_date =
  • DSELECT customer_id, order_amount FROM CUSTOMER_ORDERS WHERE order_date = '2023-
  • E`sql SELECT TOP 5 customer_id, AS total_amount FROM CUSTOMER_ORDERS WHERE

How the community answered

(51 responses)
  • A
    76% (39)
  • B
    2% (1)
  • C
    2% (1)
  • D
    6% (3)
  • E
    14% (7)

Explanation

Option A is correct because it combines all required elements: a WHERE order_date = '2023-01-15' clause to filter by the specific date, SUM(order_amount) AS total_amount to aggregate each customer's total, GROUP BY customer_id to collapse rows per customer, ORDER BY total_amount DESC to rank by highest spender, and LIMIT 5 (or equivalent) to return only the top 5.

Why the distractors fail:

  • B omits the WHERE date filter, so it aggregates across all dates, not just 2023-01-15.
  • C appears structurally similar to A but is missing either the ORDER BY or LIMIT clause, meaning results aren't ranked or capped at 5.
  • D selects raw order_amount without SUM() or GROUP BY, returning individual order rows rather than aggregated customer totals.
  • E uses SELECT TOP 5 (SQL Server syntax) but lacks GROUP BY, so the aggregation is broken and results are undefined.

Memory tip: Think of the query as a pipeline - filter first (WHERE), group and sum (GROUP BY + SUM), rank (ORDER BY DESC), trim (LIMIT 5). Any option missing a step in this pipeline will produce wrong results.

Topics

#SELECT statements#GROUP BY aggregation#ORDER BY sorting#WHERE filtering

Community Discussion

No community discussion yet for this question.

Full SOL-C01 Practice