0
0
SQLquery~10 mins

Why outer 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 customers and their orders, including customers with no orders.

SQL
SELECT customers.name, orders.order_id FROM customers [1] orders ON customers.id = orders.customer_id;
Drag options to blanks, or click blank then click option'
ARIGHT JOIN
BLEFT OUTER JOIN
CINNER JOIN
DCROSS JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN excludes customers without orders.
Using CROSS JOIN creates all combinations, not what we want.
2fill in blank
medium

Complete the code to select all orders and their customers, including orders without customers.

SQL
SELECT orders.order_id, customers.name FROM orders [1] customers ON orders.customer_id = customers.id;
Drag options to blanks, or click blank then click option'
AINNER JOIN
BFULL JOIN
CRIGHT OUTER JOIN
DLEFT JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN excludes orders without customers.
Using RIGHT OUTER JOIN keeps all rows from the right table, not orders.
3fill in blank
hard

Fix the error in the query to include all customers and orders, even if no match exists.

SQL
SELECT c.name, o.order_id FROM customers c [1] JOIN orders o ON c.id = o.customer_id;
Drag options to blanks, or click blank then click option'
ARIGHT
BINNER
CLEFT
DFULL OUTER
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN excludes customers without orders.
Using RIGHT JOIN keeps all orders, not customers.
4fill in blank
hard

Fill both blanks to select all customers and orders, showing NULL where no match exists.

SQL
SELECT [1].name, [2].order_id FROM customers [1] LEFT JOIN orders [2] ON [1].id = [2].customer_id;
Drag options to blanks, or click blank then click option'
Ac
Bo
Ccustomers
Dorders
Attempts:
3 left
💡 Hint
Common Mistakes
Using table names without alias when aliases are used in JOIN.
Mixing aliases and full table names incorrectly.
5fill in blank
hard

Fill all three blanks to select all customers and orders, including unmatched rows, using FULL OUTER JOIN.

SQL
SELECT [1].name, [2].order_id FROM [1] FULL OUTER JOIN [3] ON [1].id = [3].customer_id;
Drag options to blanks, or click blank then click option'
Acustomers
Borders
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN excludes unmatched rows.
Mixing table names incorrectly in ON clause.