The February Cohort

An easy SQL interview practice problem on DataDriven. Write the query and run it against a real database, with instant feedback.

Domain
SQL
Difficulty
easy
Seniority
L3
Asked in
Amazon

Problem

The retention team is running a re-engagement campaign targeting the February 2025 signup cohort. Pull the full profile for every user who signed up that month.

One signup window. One cohort. Who joined the club?

Tables

users

Columns: user_id INTEGER, username TEXT, email TEXT, signup_date TEXT, account_status TEXT, age_bucket TEXT

users: 10 of 200 rows
user_idusernameemailsignup_dateaccount_statusage_bucket
100alicealice@example.com2025-02-02inactive25-34
197aaron42aaron42@example.com2026-03-03suspended35-44
294 ameliaamelia@example.com2024-04-04pending_verification45-54
391arjun arjun@example.com2025-05-05active55-64
488ava99ava99@example.com2026-06-06inactive65+
585andrew_kandrew_k@example.com2024-07-07suspendedNULL
682anikaanika@example.com2025-08-08 16:34:00pending_verification18-24
779aidenaiden@example.com2026-09-09 14:53:00active25-34
876aria_baria_b@example.com2024-10-10inactive35-44
973brianbrian@example.com2025-11-11suspended45-54

Expected output

First 5 of 9 rows
user_idusernameemailsignup_dateaccount_statusage_bucket
100alicealice@example.com2025-02-02inactive25-34
1264bilalbilal@example.com2025-02-14inactiveNULL
2428celineceline@example.com2025-02-26inactive55-64
3592evelynevelyn@example.com2025-02-10inactive35-44
4756gunnargunnar@example.com2025-02-22inactive18-24

Worked solution and explanation

What this is really asking

This is a one-month cohort cut dressed up as campaign targeting. The skill is anchoring year and month in the same predicate on signup_date: anyone can find February, but the trap is finding every February. signup_date spans several years, so a month-only filter like strftime('%m', signup_date) = '02' quietly adds the February 2026 signups to a 2025 list. A hand-rolled range that ends on the wrong day of February either drops time-stamped signups or is not a date at all. Either way, the campaign mails the wrong people.

Building it

Step 1: Decide what identifies the cohort

The cohort is one calendar month in one calendar year, so its key is the year-month prefix of signup_date, never the month alone. The column is ISO text, and a few rows carry a time of day after the date, so whatever you compare must ignore the time.

Step 2: Format the date down to year and month

strftime('%Y-%m', signup_date) turns every value, with or without a time part, into the same 'YYYY-MM' shape. One equality against '2025-02' then binds both components at once, so no year can leak in and no day count has to be known.

Step 3: Return the whole row, every status

"Full profile" means every column, so SELECT * is the honest projection here. Add no account_status filter and no handling for a missing age_bucket: the cohort is everyone who signed up that month.

One month in one year
SELECT * FROM users WHERE strftime('%Y-%m', signup_date) = '2025-02'

The year-month key of signup_date pins the cohort in a single comparison.

Month only
strftime('%m', signup_date) = '02' matches February of every year in users. On this data it adds the February 2026 signups to the 2025 cohort: 12 rows where the answer has 9.
Year and month together
strftime('%Y-%m', signup_date) = '2025-02' matches one month in one year and nothing else, whatever time of day a signup was stamped with.

Common follow-up questions