SpinTheMic
Pro

Explain it in 60 seconds

Comparing rows with LAG and LEAD

Data Analyst · SQL for Analytics · Intermediate

What do LAG and LEAD do, and what are typical uses?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • Access previous/next row's value.
  • Period-over-period change.
  • Time between events.
  • PARTITION BY entity, ORDER BY time.
  • Default value for edges.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics