Retail · SQL
Counting October 2023 orders as a baseline fact-check for a revenue investigation
Independent grading: 100/100(verify, opens in a new tab)
Problem
Nura Ibrahim at Meridian Retail (simulated retailer) was leading a revenue gap investigation and needed one verified fact before the senior analysts could proceed: the total number of orders taken in October 2023. The question was simple, but the answer had to be exact and reproducible.
What I did
Using COUNT(*) against the orders table, I filtered with a half-open date range, created_at >= '2023-10-01' AND created_at < '2023-11-01', so that any time-of-day component on 31 October would not accidentally be excluded. Aliasing the result as total_orders made the single-column output immediately readable without further explanation. The choice of COUNT(*) over a column-specific count was deliberate, since counting every row is the right approach when no nulls need to be filtered.
Finding
Meridian took 610 orders in October 2023, confirmed as the exact ground-truth figure by the reviewer.
Outcome
The verified count gave the senior analysts a fixed baseline to anchor their revenue reconciliation work.
select count(*) as total_orders from orders where created_at>='2023-10-01' and created_at<'2023-11-01'
The half-open upper bound ensures no October orders are missed regardless of the time stored in created_at, and the alias makes the output self-labelling.
Next step
A useful follow-on would be to split the 610 orders by order status to see immediately which statuses make up that count, rather than treating it as a single undifferentiated total.
- COUNT with GROUP BY and ORDER BY in SQL
- Safe inclusive date-range filtering with >= and < in SQL