Hires per year

dates

Hires 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 NameType
employee_idBIGINT
nameVARCHAR
departmentVARCHAR
salaryBIGINT
manager_idBIGINT
hire_dateDATE

employeesExample Input

employee_idnamedepartmentsalarymanager_idhire_date
1Ravi KumarExecutive240000NULL2018-01-15
2Mei LinEngineering18500012018-06-04
3Sofia RossiEngineering14200022019-02-18
4James ParkEngineering12800022019-09-02
7Diego AlvarezAnalytics16800012018-10-22
8Hannah WeberAnalytics13400072020-01-13

Example Output

hire_yearhires
20183
20192
20201

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.