Transactions that do not balance

SQLHard14 minStripe style

Your task

In double-entry bookkeeping every transaction must sum to zero. Find any that do not. Return txn_id and imbalance_cents, ordered by transaction.

If the books are clean, the correct answer is no rows.

Tables

ledger_account
idINTEGERnameTEXTkindTEXT
1Cashasset
2Revenueincome
3Feesexpense
4Refundsexpense
entry
idINTEGERtxn_idINTEGERaccount_idINTEGERamount_centsINTEGERbooked_onTEXT
11001500002026-01-05
21002-500002026-01-05
31011-15002026-01-05
4101315002026-01-05
51021320002026-02-09
61022-320002026-02-09
More rows not shown