Monthly Transactions I
Preview mode. Log in to edit, run, submit, and save progress.
Monthly Transactions I
You are given a table of financial transactions. Each transaction has a country, a state (either 'approved' or 'declined'), an amount, and a date. Write a SQL query to find for each month and country: the total number of transactions, the number of approved transactions, the total transaction amount, and the total approved transaction amount. Return the result in any order.
Examples
Group by month (YYYY-MM) and country. Count all transactions, count approved ones, sum all amounts, sum approved amounts.
Approach hint
Start with a simple approach, explain the trade-off, then move toward a cleaner or more scalable solution.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.