0
0
SQLquery~10 mins

Join order and performance impact 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 columns from the two tables joined on the customer ID.

SQL
SELECT * FROM customers [1] orders ON customers.customer_id = orders.customer_id;
Drag options to blanks, or click blank then click option'
AJOIN
BWHERE
CGROUP BY
DORDER BY
Attempts:
3 left
💡 Hint
Common Mistakes
Using WHERE instead of JOIN to combine tables.
Using GROUP BY or ORDER BY which are for grouping or sorting, not joining.
2fill in blank
medium

Complete the code to perform an inner join between products and sales on product_id.

SQL
SELECT products.name, sales.quantity FROM products [1] JOIN sales ON products.product_id = sales.product_id;
Drag options to blanks, or click blank then click option'
ALEFT
BRIGHT
CFULL
DINNER
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEFT or RIGHT join which include unmatched rows from one table.
Using FULL join which includes unmatched rows from both tables.
3fill in blank
hard

Fix the error in the join condition to correctly join employees and departments on department_id.

SQL
SELECT employees.name, departments.name FROM employees JOIN departments ON employees.[1] = departments.department_id;
Drag options to blanks, or click blank then click option'
Adept_id
Bdepartment
Cdepartment_id
Ddept
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong or incomplete column name in the join condition.
Using a column that does not exist in the employees table.
4fill in blank
hard

Fill both blanks to write a query that joins orders and customers, selecting order_id and customer name, filtering only orders with amount greater than 100.

SQL
SELECT orders.order_id, customers.name FROM orders [1] JOIN customers ON orders.customer_id = customers.customer_id WHERE orders.amount [2] 100;
Drag options to blanks, or click blank then click option'
AINNER
B>
C<
DLEFT
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEFT join which includes unmatched rows.
Using < instead of > in the WHERE clause.
5fill in blank
hard

Fill all three blanks to write a query that joins three tables: sales, products, and categories. Select product name and category name for sales with quantity less than 50.

SQL
SELECT products.name, categories.name FROM sales [1] JOIN products ON sales.product_id = products.product_id [2] JOIN categories ON products.category_id = categories.category_id WHERE sales.quantity [3] 50;
Drag options to blanks, or click blank then click option'
AINNER
B<
DLEFT
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEFT join which includes unmatched rows.
Using > instead of < in the WHERE clause.