Retail · SQL
Mapping order status distribution to support a CFO revenue investigation
Independent grading: 100/100(verify, opens in a new tab)
Problem
Meridian Retail (simulated retailer) CFO Nura Ibrahim flagged a revenue discrepancy and needed a starting point before any filtering could begin. The specific question was: what distinct order statuses exist in the orders table, and how many orders carry each status?
What I did
To answer this cleanly, I grouped every row in the orders table by its status column and counted rows per group using COUNT(*). Sorting the result by count descending meant Nura could read volume distribution at a glance without scanning an unsorted list. A column alias, Order_Count, kept the output self-explanatory rather than leaving an unlabelled count column.
Finding
The orders table contains 7 distinct statuses, with delivered being the dominant group at 14,061 orders and refunded the smallest at 949.
Outcome
Nura received a clean, ranked status distribution that established the foundation for separating gross revenue from net revenue in the next steps of the investigation.
SELECT status, COUNT(*) AS "Order_Count" FROM orders GROUP BY status ORDER BY COUNT(*) DESC
This query groups every row by status, counts each group, and sorts descending so the most common status appears first, giving an immediate sense of order volume distribution.
Next step
A useful next cut would be filtering to a specific date range, such as the month Nura flagged, to see whether the status distribution shifts in that period compared to the full table.
- GROUP BY with COUNT(*) aggregation
- ORDER BY on aggregated columns
- Column aliasing for readable output