medium10 pts · first answer countschurn-preventionsql
SQL: active last month, not this month
The table `activity(customer_id, month)` has one row per customer per active month. Which query lists customers active in January 2026 but not in February 2026?
-- A
SELECT j.customer_id
FROM activity j
LEFT JOIN activity f
ON f.customer_id = j.customer_id AND f.month = '2026-02'
WHERE j.month = '2026-01' AND f.customer_id IS NULL;
-- B
SELECT customer_id FROM activity
WHERE month = '2026-01' AND month <> '2026-02';
-- C
SELECT j.customer_id
FROM activity j
JOIN activity f ON f.customer_id = j.customer_id
WHERE j.month = '2026-01' AND f.month = '2026-02';
-- D
SELECT customer_id FROM activity
WHERE month IN ('2026-01', '2026-02');Discussion 0
Join free to post in the discussion.
Related questions
- Spot an early churn signalCustomer Success Manager
- Follow up a detractorCustomer Success Manager
- What net negative churn meansCustomer Success Manager
- Average customer lifetimeCustomer Success Manager
- Exit survey at cancellationCustomer Success Manager
- What multithreading meansCustomer Success Manager
- Why talk to churned customersCustomer Success Manager
- Reading a retention curveCustomer Success Manager