Your question is Monthly KPI SQL With Joins. Start with the requirements and the four 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.
The Nature Conservancy needs a monthly operational KPI view for regional management reporting. Write a PostgreSQL query that combines program activity and finance data without double-counting either source.
LAG.| Column | Type | Description |
|---|---|---|
| region_idPK | INT | Unique regional identifier |
| region_name | VARCHAR(100) | Name of the operating region |
| Column | Type | Description |
|---|---|---|
| program_idPK | INT | Unique program identifier |
| region_id | INT | Owning region |
| program_name | VARCHAR(150) | Program name |
| Column | Type | Description |
|---|---|---|
| activity_idPK | INT | Unique activity identifier |
| program_id | INT | Related conservation program |
| activity_date | DATE | Date of the activity |
| activity_status | VARCHAR(30) | Operational status |
| hours | NUMERIC(10,2) | Hours recorded for the activity |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique finance transaction identifier |
| program_id | INT | Program charged for the transaction |
| transaction_date | DATE | Transaction posting date |
| amount | NUMERIC(12,2) | Transaction amount |
| expense_category | VARCHAR(60) | Finance expense category |