Back to Practice
#0370

Churned Users With No Recent Event

MediumSQL24 min20 XP

Problem

Return user_id values whose latest event_date is before 2026-02-01.

Why This Matters

SQL interviews usually test whether you can turn a business question into the right rows, grouping level, join type, and edge-case behavior.

Schema

events(user_id INTEGER, event_date TEXT)

Examples

Example 1
Inputusers 1 and 3 last active in January
Output1 and 3

MAX(event_date) gives each user’s latest activity date.

Constraints

  • Return only the requested columns.
  • Use deterministic ORDER BY when multiple rows are returned.
  • Assume SQLite-compatible SQL unless the prompt states otherwise.
CodeSQL
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core SQL case
Inputusers 1 and 3 last active in January
Expected[[1],[3]]

MAX(event_date) gives each user’s latest activity date.

Hidden Test Categories
Empty or missing matchesDuplicate rows or tiesNULL values where the pattern commonly breaks