SQL Practice Logo

SQLPractice Online

Scenario SQL Question

LAG and LEAD for Salary Comparison

Build mastery in Ctes Window with this scenario-based SQL challenge and live execution support.

Problem Statement

For each employee ordered by hire date within their department, show their salary compared to the previous and next hired employee. Include employee name, hire date, salary, previous employee's salary, and next employee's salary.

Relevant Tables

employeesdepartments