Welcome to the SQL screen.
The question is on your right: Compare Current Month Spend vs Budget. Read through the requirements and the three tables first.
Run and submit your code as often as you need. You also have five interviewer messages this session - want to talk through your approach, or are you ready to start coding?
You are given monthly spend and budget data. Write a PostgreSQL query that compares actual versus budgeted spend by department for the current month, returning each department’s actual spend, budgeted spend, variance, and variance percentage. Use the current month based on CURRENT_DATE.
| Column | Type | Description |
|---|---|---|
| department_idPK | INT | Primary key for the department |
| department_name | VARCHAR(100) | Department display name |
| Column | Type | Description |
|---|---|---|
| spend_idPK | INT | Primary key for the spend record |
| department_id | INT | References the department that incurred the spend |
| spend_date | DATE | Date the spend was recorded |
| amount | DECIMAL(12,2) | Actual spend amount |
| Column | Type | Description |
|---|---|---|
| budget_idPK | INT | Primary key for the budget record |
| department_id | INT | References the department assigned the budget |
| budget_month | DATE | First day of the budget month |
| budget_amount | DECIMAL(12,2) | Budgeted spend amount |