Lesson 25 — Ultimate: cohort report
Boss level: a cohort report
A cohort is a group of users who started at the same time — for example, everyone who signed up in January. A cohort report shows, per signup month, how many users there are and how many were still active later. Build it with a CTE for each user's signup month, a LEFT JOIN to activity, and COUNT(DISTINCT ...) so a user active many times counts once.
COUNT(DISTINCT CASE WHEN a.month = '2026-03' THEN u.id END)
(CASE without ELSE gives NULL, and COUNT skips NULLs.)
Why it matters: "do the users we got in January stick around?" is the key growth question for any app — this is how analysts answer it.
Fill in the active_in_march column the same way as active_in_feb. Expected: Jan cohort 3 users, 2 in Feb, 1 in March.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based SQL Deep Dive courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for SQL Deep Dive books — check the publication year so the examples match current versions.
Search Amazon →