Skip to main content

LAG & LEAD

Learn LAG & LEAD (Window Functions, MySQL) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Introduction LAG(col, n, default) reads the value from n rows before the current row and LEAD from n rows after , within the ordered partition. They replace self-joins for "compare with previous/next row".

More lessons in Window Functions