You are given sales activity from Coca-Cola Consolidated outlets and asked to turn it into actionable insight. Write a PostgreSQL query that returns, for each region and month in Q1 2024, the total revenue, total units sold, number of active outlets with at least one completed sale, and an insight label showing whether the region is Growing, Declining, or Flat compared with the prior month based on revenue. Only include completed sales in the analysis.
| Column | Type | Description |
|---|---|---|
| region_idPK | INT | Unique region identifier |
| region_name | VARCHAR(50) | Coca-Cola Consolidated region name |
| Column | Type | Description |
|---|---|---|
| outlet_idPK | INT | Unique outlet identifier |
| outlet_name | VARCHAR(100) | Outlet name |
| region_id | INT | Region assigned to the outlet |
| outlet_type | VARCHAR(30) | Outlet channel type |
| opened_date | DATE | Outlet opening date |
| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique sale identifier |
| outlet_id | INT | Outlet where the sale occurred |
| sale_date | DATE | Date of sale |
| units_sold | INT | Cases sold |
| revenue | DECIMAL(10,2) | Revenue from the sale |
| sale_status | VARCHAR(20) | Sale status |
You are practicing as a guest. Sign up free to run your code against the sample data. Your draft stays right here.