0
0
SQLquery~10 mins

Why set operations are needed in SQL - Test Your Understanding

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

Complete the code to combine two tables and get all unique rows.

SQL
SELECT * FROM table1 [1] SELECT * FROM table2;
Drag options to blanks, or click blank then click option'
AUNION
BJOIN
CINTERSECT
DWHERE
Attempts:
3 left
💡 Hint
Common Mistakes
Using JOIN instead of UNION causes a different result.
Using WHERE is incorrect for combining tables.
2fill in blank
medium

Complete the code to find rows common to both tables.

SQL
SELECT * FROM table1 [1] SELECT * FROM table2;
Drag options to blanks, or click blank then click option'
AINTERSECT
BJOIN
CEXCEPT
DUNION
Attempts:
3 left
💡 Hint
Common Mistakes
Using UNION returns all rows, not just common ones.
Using EXCEPT returns rows only in the first table.
3fill in blank
hard

Fix the error in the code to get rows in table1 but not in table2.

SQL
SELECT * FROM table1 [1] SELECT * FROM table2;
Drag options to blanks, or click blank then click option'
AUNION
BINTERSECT
CJOIN
DEXCEPT
Attempts:
3 left
💡 Hint
Common Mistakes
Using INTERSECT returns common rows, not unique ones.
Using UNION combines all rows, including duplicates.
4fill in blank
hard

Fill both blanks to combine two tables and keep all rows including duplicates.

SQL
SELECT * FROM table1 [1] SELECT * FROM table2 [2] id;
Drag options to blanks, or click blank then click option'
AUNION ALL
BUNION
CORDER BY
DWHERE
Attempts:
3 left
💡 Hint
Common Mistakes
Using UNION removes duplicates.
Using WHERE is not valid here.
5fill in blank
hard

Fill all three blanks to find rows in table1 not in table2 and sort by id.

SQL
SELECT * FROM table1 [1] SELECT * FROM table2 [2] id [3];
Drag options to blanks, or click blank then click option'
AEXCEPT
BORDER BY
CASC
DDESC
Attempts:
3 left
💡 Hint
Common Mistakes
Using DESC sorts in descending order, not ascending.
Using UNION returns all rows, not just unique ones.