Money in and money out, per account

SQLHard14 min

Your task

For each ledger account, split its entries into inflow_cents (positive amounts) and outflow_cents (negative amounts, reported as a positive number). Return name, inflow_cents and outflow_cents, ordered by name.

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