Loading exercise…
Loading exercise…
Exercises are built for a keyboard. Read the task here, then open this page on a laptop to solve it.
A retention table. A retention table has one row per cohort and one column per period, each holding the share of the cohort that was active then. Count distinct active customers per period with COUNT(DISTINCT id) FILTER (WHERE period = …), and divide by the full cohort size. A LEFT JOIN keeps customers who never bought in the base.
select segment, count(distinct customer_id) filter (where year(signup_date) = 2023) as signed_2023, count(distinct customer_id) filter (where year(signup_date) = 2024) as signed_2024 from customers group by segment
Elena Petrova wants a retention table: for each signup-year cohort, the share of its customers who bought in each quarter of 2025.
Return cohort (signup year), customers (all customers in it) and q1_pct, q2_pct, q3_pct, q4_pct: the percent of the cohort's customers with at least one completed order in that quarter, 2 decimals.
Loading the Brightline dataset…
Language
Full plan
SQL ✓ · Excel and Power BI also included
Cancel anytime · 14-day full refund · Secure payment by Stripe