What does the following calculate? SELECT month, revenue, revenue – LAG(revenue) OVER (ORDER BY month) AS mom_change FROM sales
SQL Data AnalystMedium
SQL Data Analyst — Medium
What does the following calculate? SELECT month, revenue, revenue – LAG(revenue) OVER (ORDER BY month) AS mom_change FROM sales
Explanation
This query calculates the month-over-month revenue change by subtracting each month's revenue from the previous month's. The LAG function helps to compare revenue values between consecutive months.