What do LAG and LEAD do?

SQL window functions · Freshers and experienced

Model answer

LAG returns a value from a previous row and LEAD from a following row within the partition order. They are used to compare a row to the previous one, such as day-over-day change.

Learn this topic

Window Functions: ROW_NUMBER, RANK and Running Totals in the course SQL for Beginners: Learn Databases Step by Step.

Sign in to add your own answer.

More questions