SQL Quest › SQL Interview Questions › Date Functions
Hires per Year
The head of people is preparing a slide on how fast the company grew. They want one row per year with the number of people hired that year.
Show exactly these 2 columns: hire_year (the year of hire_date, as four-digit text like 2019) and hires. Order by hire_year.
hire_date holds a full date (2019-03-15), so two people hired in the same year but on different days must still land in the same row. Seven years, seven rows.
Solve it in the browser editor →
Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect". Free accounts get 10 free challenge solves, and this can be one of them.
Schema
employees
| emp_id | name | department | position | salary | hire_date | manager_id | performance_rating |
|---|---|---|---|---|---|---|---|
| 1 | Alice Johnson | Engineering | Senior Developer | 95000 | 2019-03-15 | 5 | 4.5 |
| 2 | Bob Smith | Engineering | Developer | 75000 | 2020-06-01 | 1 | 3.8 |
| 3 | Carol Williams | Marketing | Marketing Manager | 85000 | 2018-09-20 | NULL | 4.2 |
Expected output: 7 rows — e.g. 2016 · 1 and 2020 · 12
Hint
Concepts
SELECT Date Functions strftime GROUP BY COUNT
Practise the topic: SQL practice questions · Date function practice · GROUP BY exercises
Read the concept: Time-series SQL: the ordering trap
Related questions
Where would this cost you points in an interview?
Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.
Take the readiness test