Two Sides of the Ledger
A hard SQL mock interview question on DataDriven. Practice with AI-powered feedback, real code execution, and a hire/no-hire decision.
- Domain
- SQL
- Difficulty
- hard
- Seniority
- L5
Interview Prompt
Given two tables: cloud_costs (actual cloud charges, positive amounts that represent expenses, dated by day as YYYY-MM-DD) and cost_allocs (budget allocations, positive amounts that represent inflows, recorded by month as YYYY-MM), write a query that reports a running financial balance per region on a monthly timeline. Negate the charges so they draw the balance down and keep allocations positive, truncate each charge's billing date to its month, combine both sources into one stream, net the movements per region and month, and show each region and month with the balance standing after it, ordered by region then month.
Summary
Two cost tables, one region. Which way does the balance tip?
How This Interview Works
- Read the vague prompt (just like a real interview)
- Ask clarifying questions to the AI interviewer
- Write your sql solution with real code execution
- Get instant feedback and a hire/no-hire decision