A payments team reports transaction volume by month and country. state is either 'approved' or 'declined'. For each month (formatted 'YYYY-MM') and country that has at least one transaction, report the number of transactions, the number of approved transactions, the total amount and the approved amount. A month and country with no approved transactions shows 0 for both approved columns. Write an SQL query that returns month, country, trans_count, approved_count, trans_total_amount and approved_total_amount. Order the results by month, then country.
Loading…
Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.
Ask questions, share alternate queries, and explore solutions
Your recent query executions and answer checks
This will insert the verified MySQL solution into your editor so you can study how each clause transforms the table.