All problems

Who Joined in the First Quarter?

hardSQLDates

Kestrel Labs runs a retrospective survey each spring for everybody who joined in the first quarter, and this year it is a combined cohort: every January, February and March hire the company has ever made, whatever the year they joined in.

That "whatever the year" is what makes it awkward. The hire dates run from 2020 to 2023, so there is no single span of time to look inside — three separate windows, one per year, and more windows every year the company keeps going. The thing all the wanted rows share is not a period but a position within the date text.

Note the boundary carefully: March counts and April does not. Farid Amiri joined on 18 April and is not part of this cohort.

employees — one row per person. hire_date is the day they joined, as text in YYYY-MM-DD form.

id name department_id salary hire_date manager_id
1 Ava Chen 1 145000 2021-03-14 NULL
2 Ben Ortiz 1 118000 2022-06-01 1
3 Cara Novak 1 121000 2023-01-10 1
4 Deshawn Lee 2 95000 2020-09-23 NULL
5 Elin Kask 2 88000 2022-11-05 4
6 Farid Amiri 3 76000 2023-04-18 NULL
7 Grace Kim 4 132000 2021-07-30 NULL
8 Hugo Silva 4 110000 2023-02-14 7
9 Ines Duarte 4 104000 2023-08-01 7
10 Jonas Weber 2 91000 2021-12-19 4

The table already exists in the database — there is nothing to create or load.

Task: Write a query returning a single column, name, for every employee whose hire_date falls in January, February or March of any year. December and April are both outside the cohort. Hand the rows back alphabetically by name.

Example output — shape only, on invented names.

name
Anton Reis
Lena Fournier
Rosa Kwan

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…