Write a SQL query to analyze operational performance by team and month, joining transaction data to team dimensions and calculating monthly totals and trends.
Use only transactions whose status is posted. Exclude transactions without a matching team dimension row.
team_id, team_name, month_start, transaction_count, monthly_total, prior_month_total, total_change, and percent_change.team_id, then month_start ascending. Return NULL trend values when no prior total exists or the prior total is zero.| Column | Type | Description |
|---|---|---|
| team_idPK | INT | Unique team identifier |
| team_name | VARCHAR(100) | Operational team name |
| department | VARCHAR(100) | Department containing the team |
| region | VARCHAR(50) | Operating region |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| team_id | INT | Team associated with the transaction |
| transaction_date | DATE | Date the transaction was recorded |
| amount | NUMERIC(12,2) | Transaction amount |
| status | VARCHAR(20) | Transaction processing status |