0
0
SQLquery~10 mins

Why joins 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 select all columns from the employees table.

SQL
SELECT [1] FROM employees;
Drag options to blanks, or click blank then click option'
A*
BALL
Cemployees
Dcolumns
Attempts:
3 left
💡 Hint
Common Mistakes
Using the table name instead of *
Using ALL which is not valid in SELECT
2fill in blank
medium

Complete the code to join employees with departments on department_id.

SQL
SELECT employees.name, departments.name FROM employees [1] JOIN departments ON employees.department_id = departments.id;
Drag options to blanks, or click blank then click option'
ALEFT
BRIGHT
COUTER
DINNER
Attempts:
3 left
💡 Hint
Common Mistakes
Using OUTER JOIN without specifying LEFT or RIGHT
Using LEFT JOIN which includes unmatched rows
3fill in blank
hard

Fix the error in the join condition to correctly join orders and customers.

SQL
SELECT orders.id, customers.name FROM orders INNER JOIN customers ON orders.[1] = customers.id;
Drag options to blanks, or click blank then click option'
Aorder_id
Bid
Ccustomer_id
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using orders.id which is the order's own id
Using customers.name which is not an id
4fill in blank
hard

Fill both blanks to select employee names and their department names using a join.

SQL
SELECT employees.name, departments.[1] FROM employees [2] JOIN departments ON employees.department_id = departments.id;
Drag options to blanks, or click blank then click option'
Aname
Bid
CINNER
DLEFT
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting department id instead of name
Using LEFT JOIN which includes unmatched employees
5fill in blank
hard

Fill all three blanks to select order id, customer name, and order date with a join.

SQL
SELECT orders.[1], customers.[2], orders.[3] FROM orders INNER JOIN customers ON orders.customer_id = customers.id;
Drag options to blanks, or click blank then click option'
Aid
Bname
Corder_date
Dcustomer_id
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting customer_id instead of order_date
Mixing up column names between tables