Skip to course content
Free SQL course

SQL for Data Analysis and AI

Module 02 Activity

Scenario

Three requests arrive in one morning. Each is unanswerable as written, and each becomes answerable once you pin down three things: the population, the grain, and the measure.

> 1. "How are sales looking?" > 2. "Give me our best customers." > 3. "How many orders did we complete in June?"

Task

  1. For each request, write the precise version: the population it covers, what one row represents, and

the single number or list being asked for.

  1. Note the decision you had to make that the requester did not make for you. Every one of these three

contains at least one.

  1. Write and run the SQL for the third request only.
  2. Compare what you found against what the requester probably assumed.

Deliverable

A question rewrite card for each request: the original wording, the precise wording, the ambiguity you resolved, and - for request 3 - the SQL and the answer.

Check your work

Request 3 has a surprise in it. The completed-order count is 988. But check the date range of the whole table first:

SELECT MIN(CAST(placed_at AS DATE)), MAX(CAST(placed_at AS DATE)) FROM orders;
-- 2026-06-01 | 2026-06-30

Every order in this database was placed in June 2026. So the phrase "in June" filters out nothing at all - adding WHERE placed_at >= DATE '2026-06-01' AND placed_at < DATE '2026-07-01' returns the same 988.

Say so in your answer. "988 completed orders in June - note that the dataset only covers June 2026, so this is also the all-time figure" is a materially better answer than "988". It tells the requester that their month-on-month follow-up question cannot be answered from this data.

For request 2, the ambiguity you must surface is what "best" means: most orders, highest total spend, highest average order, or most recent. These produce different customers. Pick one, state it, and move on