SQL Quest › SQL Interview Questions › Joins
Multi-Month Active Customers
Meta's retention team defines a multi-month active user as one who's shown up in at least 2 different calendar months — the minimum threshold for counting as 'retained' in their internal MAU reports. For each such customer, show name, membership, distinct_months (count of unique YYYY-MM values in their orders), and total_orders. Sort by distinct_months descending, then total_orders descending. COUNT(DISTINCT ...) over a date-formatted expression is the pattern every Meta growth team runs weekly — you'll see this exact query in Meta Data Analyst interviews dressed up in a dozen different business contexts (multi-month active users, multi-week engagers, multi-session shoppers).
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_id | name | signup_date | membership | total_orders | |
|---|---|---|---|---|---|
| 1 | John Smith | john.smith@email.com | 2023-01-15 | Gold | 15 |
| 2 | Emma Wilson | emma.wilson@email.com | 2023-03-20 | Silver | 8 |
| 3 | Michael Brown | michael.brown@email.com | 2023-02-10 | Gold | 12 |
orders
| order_id | customer_id | product | category | quantity | price | total | order_date | country | status |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | Laptop Pro | Electronics | 1 | 1299.99 | 1299.99 | 2024-01-15 | USA | completed |
| 2 | 2 | Wireless Mouse | Electronics | 2 | 49.99 | 99.98 | 2024-01-16 | Canada | completed |
| 3 | 3 | Office Chair | Furniture | 1 | 349.99 | 349.99 | 2024-01-17 | USA | completed |
Expected output: Alice | Gold | 2 | 3
Hint
Concepts
SELECT JOIN GROUP BY HAVING COUNT DISTINCT Date Functions JOIN + COUNT DISTINCT
Practise the topic: SQL practice questions · JOIN practice · GROUP BY exercises · Date function practice
In these company practice sets
Airbnb · Anthropic · Apple · Meta · Netflix · OpenAI · Revolut · Stripe · Wise · Walmart · Microsoft · LinkedIn
A SQL Quest challenge matched to patterns reported for these companies — not a question any of them has published.
Related questions
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