Back to Practice
#0340
Funnel Step Counts
MediumSQL24 min20 XP
Problem
Return step and users_count for each event_name.
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_name TEXT)
Examples
Example 1
Inputvisit/signup/purchase events
Outputvisit 3, signup 2, purchase 1
COUNT DISTINCT avoids double-counting repeated events from the same user.
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
Inputvisit/signup/purchase events
Expected[["purchase",1],["signup",2],["visit",3]]
COUNT DISTINCT avoids double-counting repeated events from the same user.
Hidden Test Categories
Empty or missing matchesDuplicate rows or tiesNULL values where the pattern commonly breaks