0
0
SQLquery~10 mins

Set operation column matching rules 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 select all unique names from two tables using UNION.

SQL
SELECT name FROM employees UNION SELECT [1] FROM managers;
Drag options to blanks, or click blank then click option'
Aname
Bsalary
Cid
Ddepartment
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting different columns in each SELECT statement causes errors.
Using columns with incompatible data types.
2fill in blank
medium

Complete the code to combine salaries from two tables using UNION ALL.

SQL
SELECT salary FROM full_time UNION ALL SELECT [1] FROM part_time;
Drag options to blanks, or click blank then click option'
Ahours
Bname
Csalary
Dposition
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting different columns causes errors.
Using UNION instead of UNION ALL when duplicates are needed.
3fill in blank
hard

Fix the error in the set operation by choosing the correct column to match.

SQL
SELECT id, name FROM customers INTERSECT SELECT [1], name FROM orders;
Drag options to blanks, or click blank then click option'
Aname
Bid
Ccustomer_id
Dorder_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using columns with different data types or meanings.
Mismatching the number of columns in SELECT statements.
4fill in blank
hard

Fill both blanks to correctly combine product names and prices from two tables using UNION.

SQL
SELECT [1], [2] FROM products_a UNION SELECT product_name, price FROM products_b;
Drag options to blanks, or click blank then click option'
Aproduct_name
Bprice
Cname
Dcost
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting columns with incompatible data types.
Mismatching the order of columns.
5fill in blank
hard

Fill all three blanks to correctly perform a UNION of employee details with matching columns.

SQL
SELECT [1], [2], [3] FROM staff UNION SELECT emp_name, emp_salary, emp_dept FROM employees;
Drag options to blanks, or click blank then click option'
Aname
Bsalary
Cdepartment
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using columns with different meanings or data types.
Mismatching the number of columns.