Skip to content
RED SAGSkills

Cumulative Hires by Year

Using each employee's hire_date, count hires per calendar year and keep a running total of all hires up to and including that year. Only years with at least one hire appear. hire_year must be an integer.

Return columns hire_year, hires, cumulative_hires. Order by hire_year ascending.

Schema

CREATE TABLE employees (
  emp_id INTEGER PRIMARY KEY,
  name TEXT NOT NULL,
  hire_date TEXT NOT NULL
);

Sample data

employees

emp_idnamehire_date
1Abe2021-03-15
2Bo2021-11-01
3Cy2022-02-10
4Di2023-06-30
5Ed2023-07-01
6Flo2023-12-31
7Gil2025-01-02
Hint 1

Aggregate to one row per year, then apply SUM(...) OVER (ORDER BY year).

Good practice for: Data Analyst, Business Analyst, Data Scientist

SQL (SQLite)

Run checks your query on the sample data (Ctrl + '). Submit also checks hidden databases.