Amazon inventory managers need to understand seasonal demand shifts. To do this, they compare the sales performance of products in the current month against their performance in the same month of the previous year.
Write an SQL query to report the total quantity sold for each item in each month, alongside the total quantity sold for that same item in the same month of the preceding year.
Rules:
- The output should include the item name, the month (1-12), the current year, the current year's total units, and the previous year's total units.
- If an item had no sales in the same month of the previous year, the previous year's total should be 0.
- Only include rows where there were sales in the "current" year being reported.
- Output columns: item_name, sale_month, sale_year, current_year_units, prev_year_units.
- Results must be sorted by item_name ASC, sale_year ASC, and sale_month ASC.