🎯 Few days left this month Support SQLTest.online and help us keep SQL practice free for everyone. Donate today →
SQL code copied to buffer
Task 132:

Monthly Payments with Empty Months

MySQL
The payment table has payments from May 2005 to February 2006, but not every month has them. Build a monthly report for every month from May 2005 to February 2006 inclusive, including the months without payments.
Output columns: year, month (numbers), payments (the number of payments, 0 for a month without payments) and total (the sum of amount, 0 for a month without payments). Sort by year and month.
Expected result Columns: 4 · Rows: 10
year month payments total

Sample rows open after wrong checks: 0 of 2

Write your query below and click "Check it!". Tables are described in the right pane.

Tutorial
The query result will appear here. Ctrl+Enter - Run query