Your question is Identify Financial Performance Drivers. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
You are given monthly financial data and asked to identify the main drivers of performance by business segment. Write a PostgreSQL query that joins the tables, calculates revenue, cost, and gross profit by segment for a given month, and classifies each segment as growth, stable, or decline based on gross profit margin.
| Column | Type | Description |
|---|---|---|
| segment_idPK | INT | Primary key for the segment |
| segment_name | VARCHAR(100) | Business segment name |
| region | VARCHAR(50) | Operating region |
| Column | Type | Description |
|---|---|---|
| fact_idPK | INT | Primary key for the financial fact row |
| segment_id | INT | References the segment being measured |
| month_end | DATE | Month-end reporting date |
| revenue | NUMERIC(12,2) | Reported revenue for the period |
| cost | NUMERIC(12,2) | Reported cost for the period |
| is_adjusted | BOOLEAN | Whether the record has been adjusted |