SQL QuestSQL Interview Questions › Date Functions

Customer Signup Quarter (Date + CASE)

MediumFreeQuerying BasicsDate FunctionsConditional Logic

A cohort analyst wants every customer labeled by signup quarter (Q1Q4) for time-series cohort grids.

Show customer_id, name, signup_date, and quarter ('Q1' for months 01–03, 'Q2' for 04–06, 'Q3' for 07–09, 'Q4' for 10–12). Order by signup_date.

The pattern: strftime('%m', signup_date) returns a 2-char month string, then a CASE expression buckets it. Quarter math feels trivial but it's one of the most repeated reporting patterns in business SQL.

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".

Schema

customers

customer_idnameemailsignup_datemembershiptotal_orders
1John Smithjohn.smith@email.com2023-01-15Gold15
2Emma Wilsonemma.wilson@email.com2023-03-20Silver8
3Michael Brownmichael.brown@email.com2023-02-10Gold12

Expected output: quarter = 'Q2'

Hint

CASE WHEN strftime('%m', signup_date) IN ('01','02','03') THEN 'Q1' WHEN ... END AS quarter. Compare to 2-char strings since strftime emits the leading zero.

Concepts

SELECT Date Functions strftime CASE

Practise the topic: SQL practice questions · Date function practice · CASE WHEN practice

In these company practice sets

Ramp · Revolut · Wise

A SQL Quest challenge matched to patterns reported for these companies — not a question any of them has published.

Related questions

Employee Tenure BandsMedium · FreeQuarterly Hiring Cohort ReportMedium · FreeCustomer Recency AnalysisMedium · FreeMonthly Order TrendsMedium · FreeDate Functions: How Long Ago?Medium · FreeMonthly Order Volume in 2024Medium · Free

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