Back to Practice
#0345

Users Active on Web and App

EasySQL15 min10 XP

Problem

Return user_id values that appear in both web_events and app_events.

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

web_events(user_id INTEGER); app_events(user_id INTEGER)

Examples

Example 1
Inputusers 2 and 3 appear in both
Output2, 3

INTERSECT keeps only values present in both queries.

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 2 and 3 appear in both
Expected[[2],[3]]

INTERSECT keeps only values present in both queries.

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