
Hires per year
easyHires per year
LinkedIn SQL Interview Question
LinkedIn's talent team is presenting hiring trends to leadership and needs a count of new hires for each year.
Count the employees hired each year. Show the year as hire_year and the count as hires. Sort the rows by hire_year, earliest first.
Asked of
- Data Analyst
- Business Analyst
- BI Analyst
employeesTable16 rows
| Column Name | Type |
|---|---|
| employee_id | BIGINT |
| name | VARCHAR |
| department | VARCHAR |
| salary | BIGINT |
| manager_id | BIGINT |
| hire_date | DATE |
employeesExample Input
| employee_id | name | department | salary | manager_id | hire_date |
|---|---|---|---|---|---|
| 1 | Ravi Kumar | Executive | 240000 | NULL | 2018-01-15 |
| 2 | Mei Lin | Engineering | 185000 | 1 | 2018-06-04 |
| 3 | Sofia Rossi | Engineering | 142000 | 2 | 2019-02-18 |
| 4 | James Park | Engineering | 128000 | 2 | 2019-09-02 |
| 7 | Diego Alvarez | Analytics | 168000 | 1 | 2018-10-22 |
| 8 | Hannah Weber | Analytics | 134000 | 7 | 2020-01-13 |
Example Output
| hire_year | hires |
|---|---|
| 2018 | 3 |
| 2019 | 2 |
| 2020 | 1 |
Explanation
Ravi Kumar, Mei Lin and Diego Alvarez were all hired in 2018, so 2018 has 3 hires. Sofia Rossi and James Park joined in 2019, and Hannah Weber joined in 2020.
The example above is a small slice of the data. Your query runs against the full tables.
Company
LinkedIn
Difficulty
easy
Topic
dates
Your query
Starting the SQL engine...