Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Salary Change vs Previous Hire

Employees are ordered by hire date. Return each employee and the difference between their salary and the salary of the employee hired just before them (NULL for the first). Order by hire date.

Table schema

Employees(id INT PRIMARY KEY, name VARCHAR(10), hire_date DATE, salary INT)

Sample data

id | name | hire_date | salary
1 | Ann | 2020-01-01 | 50
2 | Bob | 2021-06-01 | 60
3 | Cy | 2022-03-01 | 55
4 | Dee | 2023-09-01 | 70

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.