0
0
SQLquery~10 mins

Finding unmatched rows with LEFT JOIN 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 who have no orders.

SQL
SELECT customers.id, customers.name FROM customers LEFT JOIN orders ON customers.id = orders.customer_id WHERE orders.customer_id IS [1];
Drag options to blanks, or click blank then click option'
AFALSE
BNOT NULL
CNULL
DTRUE
Attempts:
3 left
💡 Hint
Common Mistakes
Using = NULL instead of IS NULL
Checking for NOT NULL instead of NULL
Using INNER JOIN instead of LEFT JOIN
2fill in blank
medium

Complete the code to find products that have never been ordered.

SQL
SELECT products.id, products.name FROM products LEFT JOIN order_items ON products.id = order_items.product_id WHERE order_items.product_id IS [1];
Drag options to blanks, or click blank then click option'
ANOT NULL
BNULL
CFALSE
DTRUE
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN which excludes unmatched rows
Checking for NOT NULL instead of NULL
Using = NULL instead of IS NULL
3fill in blank
hard

Complete the code to find employees without assigned projects.

SQL
SELECT e.id, e.name FROM employees e LEFT JOIN projects p ON e.id = p.employee_id WHERE p.employee_id IS [1];
Drag options to blanks, or click blank then click option'
AFALSE
BNOT NULL
C0
DNULL
Attempts:
3 left
💡 Hint
Common Mistakes
Using = NULL instead of IS NULL
Checking for 0 or FALSE which are not correct for NULL
Using INNER JOIN instead of LEFT JOIN
4fill in blank
hard

Fill both blanks to find customers without orders and select their id and name.

SQL
SELECT customers.[1], customers.[2] FROM customers LEFT JOIN orders ON customers.id = orders.customer_id WHERE orders.customer_id IS NULL;
Drag options to blanks, or click blank then click option'
Aid
Bname
Corder_id
Dcustomer_id
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting columns from the orders table instead of customers
Using wrong column names like order_id or customer_id from orders
5fill in blank
hard

Fill all three blanks to find products without orders and select their id, name, and price.

SQL
SELECT [1], [2], [3] FROM products LEFT JOIN order_items ON products.id = order_items.product_id WHERE order_items.product_id IS NULL;
Drag options to blanks, or click blank then click option'
Aproducts.id
Bproducts.name
Cproducts.price
Dorder_items.quantity
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting columns from order_items instead of products
Missing one or more required columns