0Pricing
SQL Interview Prep · Lesson

Churn and Resurrection Queries

Identifying users who left and those who returned after a gap.

The Flip Side of Retention

If retention measures who stayed, churn measures who left, and resurrection measures who came back. Interviewers pair these with retention because they reveal whether you can reason about absence of activity, which is harder than counting presence.

The recurring trick: you cannot filter on rows that do not exist. Churn queries are fundamentally about finding the gap between a user's last activity and now (or their next activity).

Defining Churn Precisely

"Churned" is meaningless without a window. A common definition: a user is churned if they have had no activity in the last 30 days. The 30-day inactivity threshold is the business choice you must pin down.

For subscription products, churn may instead mean a cancelled or expired subscription, a status change rather than an activity gap. Clarify which model applies before writing SQL.

All lessons in this course

  1. Defining a Cohort by First Action
  2. Building a Retention Matrix
  3. Day-N and Rolling Retention
  4. Churn and Resurrection Queries
← Back to SQL Interview Prep