Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Track Fund Balance Trends by Period

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

Your question is Track Fund Balance Trends by Period. Start with the requirements and the two 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.

You need to log in / sign up to run or submit.

Problem

You are given fund ledger data and need to prepare a periodic analysis that supports budgeting and forecasting. Write a PostgreSQL query that returns one row per fund per month with the month’s beginning balance, total expenditures, ending balance, and the prior month’s ending balance. Exclude inactive funds and any transactions outside the reporting range.

Schema

funds
ColumnTypeDescription
fund_idPKINTPrimary key for each fund
fund_codeVARCHAR(20)Internal fund identifier
fund_nameVARCHAR(255)Fund name
fund_typeVARCHAR(50)Fund classification
is_activeBOOLEANWhether the fund is currently active
fund_transactions
ColumnTypeDescription
transaction_idPKINTPrimary key for each transaction
fund_idINTForeign key to funds.fund_id
transaction_dateDATETransaction posting date
transaction_typeVARCHAR(20)Transaction category: begin_balance, expenditure, or adjustment
amountNUMERIC(12,2)Signed transaction amount
Tablesfundsfund_transactions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results