

Welcome to the SQL screen for the Financial Analyst role at Rippling.
The question is on your right: Compare Department Spend to Budget. Read through the requirements and the three tables first.
Would you like to talk through your approach, or are you ready to start coding?
You are given departmental budget data and actual expense transactions. Write a PostgreSQL query that compares actual spend versus budget by department and returns each department’s budget, actual spend, variance, and variance percentage.
| Column | Type | Description |
|---|---|---|
| department_idPK | INT | Primary key for the department |
| department_name | VARCHAR(100) | Department name |
| Column | Type | Description |
|---|---|---|
| budget_idPK | INT | Primary key for the budget record |
| department_id | INT | References departments.department_id |
| budget_month | DATE | Month the budget applies to |
| budget_amount | DECIMAL(12,2) | Approved budget amount for the month |
| Column | Type | Description |
|---|---|---|
| expense_idPK | INT | Primary key for the expense transaction |
| department_id | INT | References departments.department_id |
| expense_date | DATE | Date the expense was incurred |
| amount | DECIMAL(12,2) | Expense amount |
| status | VARCHAR(20) | Expense status such as approved, pending, or rejected |