Task
You are given a table of reporting packages prepared in a finance system. Write a SQL query that returns the total number of packages prepared and the total package hours for each reporting period in 2024, grouped by month. Only include rows where the package status is Completed, and sort the results by reporting month ascending.
This mirrors a common analyst task of summarizing monthly or quarterly reporting packages such as board reporting, budget-to-actuals, grant reporting, and program financial review packets.
Schema
| column_name | type | description |
|---|
| package_id | INT | Unique package record ID |
| package_name | VARCHAR(100) | Name of the reporting package |
| reporting_period_end | DATE | End date of the reporting period |
| package_status | VARCHAR(20) | Current status of the package |
| package_hours | DECIMAL(6,2) | Hours spent preparing the package |
Sample data
| package_id | package_name | reporting_period_end | package_status | package_hours |
|---|
| 3 | Budget vs Actual | 2024-01-31 | Completed | 4.00 |
| 1 | Board Package | 2024-03-31 | Completed | 6.50 |
| 6 | Grant Report | 2024-03-31 | Draft | 2.50 |
| 8 | Program Financial Review | 2024-06-30 | Completed | 0.00 |
Expected output
| reporting_month | completed_package_count | total_package_hours |
|---|
| 2024-01 | 2 | 9.50 |
| 2024-03 | 3 | 14.50 |
| 2024-06 | 2 | 5.50 |