Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Reconcile Ledger and Bank Balances

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

Your question is Reconcile Ledger and Bank Balances. 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 ledger entries and bank transactions for a monthly financial model. Write a PostgreSQL query that reconciles the two sources by account and month, returning only accounts where the booked amount and bank amount do not match. Include the booked total, bank total, and the variance for each mismatched account-month pair.

Schema

ledger_entries
ColumnTypeDescription
entry_idPKINTPrimary key for each ledger row
account_codeVARCHAR(20)Financial account code
entry_dateDATEPosting date
amountDECIMAL(12,2)Signed ledger amount
source_systemVARCHAR(50)Origin of the entry
bank_transactions
ColumnTypeDescription
transaction_idPKINTPrimary key for each bank row
account_codeVARCHAR(20)Financial account code
transaction_dateDATEBank transaction date
amountDECIMAL(12,2)Signed bank amount
statusVARCHAR(20)Transaction status
Tablesledger_entriesbank_transactions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results