What does the following window function return for the third row? LAG(salary, 2, 0) OVER (ORDER BY hire_date)

SQL Fundamentals Hard

SQL Fundamentals — Hard

What does the following window function return for the third row? LAG(salary, 2, 0) OVER (ORDER BY hire_date)

Key points

  • LAG function looks back a specified number of rows
  • Default value is only used when there are not enough rows to look back
  • The function returns the salary of the row 2 positions before the current row

Ready to go further?

Related questions