0
0
PostgreSQLquery~10 mins

INNER JOIN execution in PostgreSQL - 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 two tables joined on the "id" column.

PostgreSQL
SELECT * FROM employees [1] departments ON employees.id = departments.id;
Drag options to blanks, or click blank then click option'
AINNER JOIN
BRIGHT JOIN
CLEFT JOIN
DFULL JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEFT JOIN instead of INNER JOIN returns unmatched rows from the left table.
Using FULL JOIN returns all rows from both tables, not just matches.
2fill in blank
medium

Complete the code to join "orders" and "customers" tables on the "customer_id" column.

PostgreSQL
SELECT orders.order_id, customers.name FROM orders [1] customers ON orders.customer_id = customers.customer_id;
Drag options to blanks, or click blank then click option'
ALEFT JOIN
BCROSS JOIN
CRIGHT JOIN
DINNER JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using CROSS JOIN returns all combinations, not just matches.
LEFT JOIN includes unmatched rows from the left table.
3fill in blank
hard

Fix the error in the join condition to correctly join "products" and "categories" on "category_id".

PostgreSQL
SELECT * FROM products INNER JOIN categories ON products.[1] = categories.category_id;
Drag options to blanks, or click blank then click option'
Acategory
Bcategory_id
Cid
Dproduct_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong column like 'category' or 'product_id' causes join errors or wrong results.
Using 'id' instead of 'category_id' mismatches the join keys.
4fill in blank
hard

Fill both blanks to create a join that selects employee names and their department names.

PostgreSQL
SELECT employees.name, departments.[1] FROM employees [2] departments ON employees.department_id = departments.id;
Drag options to blanks, or click blank then click option'
Aname
BLEFT JOIN
CINNER JOIN
Dsalary
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEFT JOIN returns employees without departments.
Selecting 'salary' instead of 'name' shows wrong data.
5fill in blank
hard

Fill all three blanks to join "sales" and "stores" tables and select store name and total sales.

PostgreSQL
SELECT stores.[1], SUM(sales.amount) AS total_sales FROM sales [2] stores ON sales.[3] = stores.id GROUP BY stores.name;
Drag options to blanks, or click blank then click option'
Aname
BINNER JOIN
Cstore_id
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEFT JOIN includes sales without matching stores.
Joining on 'date' instead of 'store_id' causes wrong matches.