File size: 364 Bytes
27ec678
 
 
1
2
3
4
-- Chargeback losses booked
-- Debits less credits on 5210 by month.
SELECT strftime(e.entry_date, '%Y-%m') AS month, -sum(l.credit - l.debit) AS value FROM ledger.journal_line l JOIN ledger.journal_entry e USING (entry_id) WHERE l.account_code IN ('5210') AND e.entry_date >= TIMESTAMP '2023-10-01' AND e.entry_date < TIMESTAMP '2026-10-01' GROUP BY 1 ORDER BY 1