Back to Practice
#0343
Union Active Users From Two Sources
EasySQL15 min10 XP
Problem
Return distinct user_id values appearing in web_events or 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
Inputuser 2 appears in both tables
Output1, 2, 3
UNION removes duplicates across both result sets.
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 2 appears in both tables
Expected[[1],[2],[3]]
UNION removes duplicates across both result sets.
Hidden Test Categories
Empty or missing matchesDuplicate rows or tiesNULL values where the pattern commonly breaks