Use LAG() window function for period-over-period comparison and date truncation
I need a monthly revenue trend with month-over-month growth rates for the board. For each month, show the year, month number, monthly revenue, previous month's revenue, and the MoM growth percentage. Order chronologically. The first month will naturally have NULL for prior month — that's fine.
Each hint you reveal reduces the XP you can earn. Try the query first.
Extract year and month from sale_date, GROUP BY them, and SUM revenue to get monthly totals
Use LAG(monthly_revenue) OVER (ORDER BY year, month) to get the previous month's value
Growth rate = (current - previous) / previous * 100. Use a subquery: aggregate in the inner query, apply LAG in the outer