0
0
SQLquery~10 mins

UNION ALL with duplicates in SQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to combine two tables including duplicates using UNION ALL.

SQL
SELECT name FROM employees [1] SELECT name FROM contractors;
Drag options to blanks, or click blank then click option'
AINTERSECT
BUNION ALL
CUNION
DEXCEPT
Attempts:
3 left
💡 Hint
Common Mistakes
Using UNION instead of UNION ALL, which removes duplicates.
Using INTERSECT or EXCEPT which do not combine all rows.
2fill in blank
medium

Complete the code to select all product IDs from two tables including duplicates.

SQL
SELECT product_id FROM sales_2023 [1] SELECT product_id FROM sales_2024;
Drag options to blanks, or click blank then click option'
AUNION ALL
BUNION
CINTERSECT
DJOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using UNION which removes duplicates.
Using JOIN which is for combining columns, not rows.
3fill in blank
hard

Fix the error in the query to include duplicates from both tables.

SQL
SELECT city FROM customers [1] SELECT city FROM suppliers;
Drag options to blanks, or click blank then click option'
AUNION ALL
BUNION
CEXCEPT
DINTERSECT
Attempts:
3 left
💡 Hint
Common Mistakes
Using UNION which removes duplicates.
Using EXCEPT or INTERSECT which filter rows.
4fill in blank
hard

Fill both blanks to combine two queries including duplicates and order the results by name.

SQL
SELECT name FROM staff [1] SELECT name FROM interns ORDER BY name [2];
Drag options to blanks, or click blank then click option'
AUNION ALL
BWHERE
CASC
DGROUP BY
Attempts:
3 left
💡 Hint
Common Mistakes
Using UNION instead of UNION ALL.
Using WHERE instead of ORDER BY direction.
5fill in blank
hard

Fill all three blanks to select all emails from two tables including duplicates, filter only active users, and order by email descending.

SQL
SELECT email FROM users_2022 WHERE status = [1] [2] SELECT email FROM users_2023 WHERE status = [3] ORDER BY email DESC;
Drag options to blanks, or click blank then click option'
A'active'
BUNION ALL
DUNION
Attempts:
3 left
💡 Hint
Common Mistakes
Using UNION which removes duplicates.
Using wrong status filter values.