Retail · SQL
Verifying October 2023 order volume to ground a revenue gap investigation
Independent grading: 100/100(verify, opens in a new tab)
Problem
The senior analysts at Meridian Retail (simulated retailer) were investigating a revenue discrepancy in October 2023 and needed one verified fact before proceeding: the total number of orders placed that month. Nura Ibrahim asked for a single, trustworthy count drawn directly from the orders table using the created_at date column.
What I did
To avoid edge cases with timestamps, I used a half-open interval in the WHERE clause, filtering for created_at >= '2023-10-01' AND created_at < '2023-11-01'. This pattern captures every timestamp within October regardless of the time component, including records at 23:59:59 on the 31st. The result column was aliased as oct_order so the output was immediately readable without needing a separate label.
Finding
The query returned 610 orders for October 2023, matching the verified ground truth exactly.
Outcome
Nura's team had a confirmed, edge-case-safe order count to anchor the broader revenue gap investigation.
SELECT COUNT(*) AS oct_order FROM orders WHERE created_at >= '2023-10-01' AND created_at < '2023-11-01';
The half-open interval ensures all timestamps within October are captured; the alias makes the single-column result self-labelling.
Next step
A useful next step would be to break the 610 orders down by status to see how many of those October orders were delivered versus cancelled or returned, which would sharpen the revenue gap diagnosis.
- SQL WHERE clause date filtering with half-open intervals
- SQL COUNT with GROUP BY and ORDER BY
- Column aliasing for readable query output