Back to Practice
#0368
Daily New Users by First Event
MediumSQL24 min20 XP
Problem
Return first_event_date and new_users_count.
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 2 first appear Jan 1
OutputJan 1 -> 2
First compute one first date per user, then count users per 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 2 first appear Jan 1
Expected[["2026-01-01",2],["2026-01-03",1]]
First compute one first date per user, then count users per date.
Hidden Test Categories
Empty or missing matchesDuplicate rows or tiesNULL values where the pattern commonly breaks