Chapter 4 · Aggregations
64. Monthly Deposit and Withdrawal Totals
Medium20 XPFinance
Create a monthly report showing total deposits and total withdrawals side by side. Return the month (as YYYY-MM), total_deposits, and total_withdrawals. Use conditional aggregation (CASE inside SUM). Order by month ascending.
Tables
- PKidINT
- FKaccount_id→ accounts.idINT
- transaction_dateTEXT
- typeTEXT
- amountREAL
- balance_afterREAL
- descriptionTEXT
- reference_numberTEXT
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.