Back to Practice
#0371

Users With Multiple Event Types

EasySQL15 min10 XP

Problem

Return user_id values that have at least two distinct event_name values.

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
Inputuser 1 has view and click
Outputuser 1

COUNT DISTINCT counts event types, not total events.

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
Inputuser 1 has view and click
Expected[[1]]

COUNT DISTINCT counts event types, not total events.

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