Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Budget vs Actual Variance Report

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Budget vs Actual Variance Report. Start with the requirements and the one table 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 need to log in / sign up to run or submit.

Problem

FinSight tracks department spending in a single budgeting table. Write a SQL query to report departments where actual spending differs from projected budget.

Requirements

  1. Return each department with its total projected budget, total actual spend, and the variance (actual_spend - projected_budget).
  2. Include only departments where the totals do not match.
  3. Add a status column that shows Over Budget when actual spend is greater than projected budget, otherwise Under Budget.
  4. Order the results by absolute variance descending, then by department name.

Schema

department_budget_actuals
ColumnTypeDescription
idPKINTPrimary key for each budget record
departmentVARCHAR(100)Department name
projected_budgetDECIMAL(12,2)Projected budget amount for the record
actual_spendDECIMAL(12,2)Actual expenditure amount for the record
report_monthDATEReporting month for the budget entry
cost_centerVARCHAR(50)Cost center associated with the record
Tablesdepartment_budget_actuals
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results