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

Longest-Serving Current Employee per Department

Return, per department, the current employee with the earliest hire date. Order by department.

Table schema

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

Sample data

id | name | dept | hire_date | left_date
1 | Ann | IT | 2019-04-01 | NULL
2 | Bob | IT | 2021-08-15 | 2024-02-01
3 | Cy | HR | 2022-01-10 | NULL
4 | Dee | HR | 2020-06-01 | NULL
5 | Eli | IT | 2022-09-01 | 2025-03-01

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.