Back to Practice
#0141

Seven Day Active Users

MediumSQL25 min20 XP

Problem

Return active_users: distinct users with event_date from 2026-01-01 through 2026-01-07 inclusive.

Why This Matters

Active-user metrics are common in product analytics and dashboards.

Schema

events(user_id INTEGER, event_date TEXT)

Examples

Example 1
Inputevents inside and outside first week of Jan
Outputcount of distinct users inside range

Repeated events by the same user count once.

Constraints

  • Return the exact requested structure.
  • Handle normal edge cases cleanly.
  • Prefer readable code over clever shortcuts.
CodeSQL
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core example
Inputevents inside and outside first week of Jan
Expectedcount of distinct users inside range

Repeated events by the same user count once.

Hidden Test Categories
boundary datesduplicatesno active users