Use GROUP BY with SUM to roll up monetary totals per category. The first 'where does our money actually live across lifecycle states' query — the question every CFO asks before close.
Pre-close ask. For my variance memo I need to see total `total_price` summed up per `financial_status` value. One row per status, with the dollar total alongside, ordered by total descending. Use `ecom_orders`. I expect `paid` to be the bulk; the question is how big the partial-refund and pending columns are. We're closing Q1 next week and I want eyes on each bucket.
| Column | Type | Key |
|---|---|---|
| order_id | INT | PK |
| customer_id | INT | FK → ecom_customers |
| order_number | TEXT | |
| financial_status | TEXT | |
| fulfillment_status | TEXT | |
| total_price | REAL | |
| subtotal | REAL | |
| tax | REAL | |
| shipping | REAL | |
| discount_total | REAL | |
| channel | TEXT | |
| created_date | TEXT | |
| processed_date | TEXT |
Each hint you reveal reduces the XP you can earn. Try the query first.
`GROUP BY financial_status` collapses 100 order rows into one row per status.
`SELECT financial_status, SUM(total_price) AS revenue FROM ecom_orders GROUP BY financial_status ORDER BY revenue DESC`. Seven rows.
The CFO will care that pending + authorized + partially_paid together represent ~$1.6K — that's the Q-end accrual question. Paid is the bulk by an order of magnitude.