0
0
SQLquery~10 mins

LEFT JOIN with NULL result rows 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 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'
ALEFT JOIN
BRIGHT JOIN
CINNER JOIN
DFULL JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN excludes customers without orders.
Using RIGHT JOIN or FULL JOIN changes which rows are included.
2fill in blank
medium

Complete the code to find customers with no orders using LEFT JOIN.

SQL
SELECT customers.name FROM customers LEFT JOIN orders ON customers.id = orders.customer_id WHERE orders.order_id [1];
Drag options to blanks, or click blank then click option'
AIS NOT NULL
BIS NULL
C= 0
D<> NULL
Attempts:
3 left
💡 Hint
Common Mistakes
Using = NULL or <> NULL which are invalid in SQL.
Using IS NOT NULL which finds customers with orders.
3fill in blank
hard

Fix the error in the query to include all customers and their orders, showing NULL for missing orders.

SQL
SELECT c.name, o.order_id FROM customers c [1] orders o ON c.id = o.customer_id WHERE o.order_id > 100;
Drag options to blanks, or click blank then click option'
ARIGHT JOIN
BINNER JOIN
CLEFT JOIN
DFULL JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN excludes customers without orders.
Filtering on right table columns in WHERE removes NULL rows.
4fill in blank
hard

Fill both blanks to select all customers and their orders, showing NULL for missing orders, and order by customer name.

SQL
SELECT [1], [2] FROM customers LEFT JOIN orders ON customers.id = orders.customer_id ORDER BY customers.name;
Drag options to blanks, or click blank then click option'
Acustomers.name
Borders.order_id
Ccustomers.id
Dorders.customer_id
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting wrong columns like IDs that don't show meaningful info.
Not ordering by customer name as requested.
5fill in blank
hard

Fill all three blanks to create a query that lists all customers, their order IDs, and filters to show only customers with no orders.

SQL
SELECT [1], [2] FROM customers [3] orders ON customers.id = orders.customer_id WHERE orders.order_id IS NULL;
Drag options to blanks, or click blank then click option'
Acustomers.name
Borders.order_id
CLEFT JOIN
DINNER JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN excludes customers without orders.
Not checking for NULL order_id to find customers without orders.