Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Question: Explain the purpose of the SQL LEAD() and LAG() functions.
Answer: The LEAD() function is used to access the next row's data in the result set, while the LAG() function is used to access the previous row's data.

Example:

SELECT employee_name, salary, LEAD(salary) OVER (ORDER BY salary) AS NextSalary FROM Employee;
Is it helpful? Yes No

Most helpful rated by users:

©2025 WithoutBook