LAG, LEAD

Published July 25, 2026 By Sai Sree Ram Gundepudi

LAG and LEAD

Use LAG and LEAD to get values from previous/next rows.

SELECT employee_id, hire_date,
       LAG(hire_date) OVER (ORDER BY hire_date) AS prev_hire,
       LEAD(hire_date) OVER (ORDER BY hire_date) AS next_hire
FROM employees;

Was this solution helpful?

Your feedback helps improve our technical knowledge repository.

Share this article