Retrieve Next Employee Salary Using LEAD

Find the next employee's salary using a window function.

sql

SELECT id, salary, LEAD(salary) OVER (ORDER BY id) AS next_salary FROM employees;

This query uses the LEAD() window function to retrieve the value of the "salary" column from the subsequent row, ordered by the "id" column, within the "employees" table.

PromptDB can make mistakes. Please double-check responses.