What does LAG(revenue, 1) OVER (ORDER BY month) return for the first row?

SQL Data Analyst Medium

SQL Data Analyst — Medium

What does LAG(revenue, 1) OVER (ORDER BY month) return for the first row?

Key points

  • The LAG function looks at the previous row based on the specified order.
  • In this case, since the first row has no previous row, the result is NULL.
  • This is useful for calculating differences between consecutive rows.

Ready to go further?

Related questions