▸_sqlgym

63. UNION ALL vs UNION: Counting Logins

MediumSet OperationsUNION ALLUNIONduplicatesCOUNT

UNION ALL keeps duplicates; UNION removes them. The difference is observable: stack two login logs and count the rows each way.

Task: report two counts in a single row — the number of rows when combining the two logs with UNION ALL (duplicates kept) and with UNION (distinct users).

Return columns all_count, distinct_count. Single row.

Tables
Loading schema…
Expected outputrow order doesn't matter
Computing expected output…

This is the result for the example data above. On Submit your query is graded against this example plus 4 hidden edge cases 5test cases in all. A sloppy query that only fits the example won't pass.

SQL
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.