Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Quarterly Expense Forecast Rollup
00:00
5 left

Quarterly Expense Forecast Rollup

MediumSQL · PostgreSQL

Quarterly Expense Rollup

Problem

You are given raw expense transactions and a quarterly forecast table. Your task is to structure the expense data into a quarter-level report that a VP can review quickly. The output should compare posted actual spend against forecasted spend by quarter and department, and include the variance between them.

Tables

Expenses
Name

expense_id

Type

INT

Description

Primary key for each expense row

Name

expense_date

Type

DATE

Description

Date the expense was incurred

Name

department

Type

VARCHAR(50)

Description

Cost center or department name

Name

amount

Type

DECIMAL(12,2)

Description

Expense amount; may be negative for credits

Name

status

Type

VARCHAR(20)

Description

Posting status such as posted, pending, or void

Quarter forecast
Name

forecast_quarter

Type

DATE

Description

Quarter start date used as the forecast key

Name

department

Type

VARCHAR(50)

Description

Department name

Name

forecast_amount

Type

DECIMAL(12,2)

Description

Planned quarterly spend

Representative Rows

expenses
12024-01-05Marketing1200posted
42024-04-02Sales900pending
72024-06-30Finance-50posted
102024-08-01Engineering2000posted
quarter_forecast
2024-01-01Marketing2500
2024-04-01Finance500
2024-07-01Engineering2200
2024-10-01Legal300
Tablesexpensesquarter_forecast
Interviewer

Your question is Quarterly Expense Forecast Rollup. Start with the requirements and the two tables in the Question tab.

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.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.