Audit check: in double-entry bookkeeping total debits must equal total credits for every journal entry. NULL debit or credit means 0. Because of floating-point storage, treat an entry as balanced when ABS(total_debit - total_credit) < 0.01. Return entry_id, total_debit, total_credit and difference (= total_debit - total_credit), all ROUND 2, for unbalanced entries only. Order by ABS(difference) DESC, then entry_id.
| Column | Type |
|---|---|
| entry_id | TEXT |
| line_no | INTEGER |
| account | TEXT |
| debit | REAL |
| credit | REAL |
| entry_id | line_no | account | debit | credit |
|---|---|---|---|---|
| JE1 | 1 | Cash | 1000 | NULL |
| JE1 | 2 | Revenue | NULL | 1000 |
| JE2 | 1 | Rent | 500 | NULL |
| JE2 | 2 | Cash | NULL | 450 |
| JE3 | 1 | Travel | 200 | NULL |
| JE3 | 2 | Meals | 100 | NULL |
| JE3 | 3 | Card Payable | NULL | 300 |
| JE4 | 1 | Supplies | 75.5 | NULL |
| entry_id | total_debit | total_credit | difference |
|---|---|---|---|
| JE4 | 75.5 | 0 | 75.5 |
| JE2 | 500 | 450 | 50 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Bench Periods Between Project Allocations · Active Headcount per Department ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.