0
0
PostgreSQLquery~10 mins

FULL OUTER JOIN 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 both tables using a full outer join.

PostgreSQL
SELECT * FROM employees [1] departments ON employees.dept_id = departments.id;
Drag options to blanks, or click blank then click option'
AFULL OUTER JOIN
BINNER JOIN
CLEFT JOIN
DRIGHT JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN which only returns matching rows.
Using LEFT JOIN or RIGHT JOIN which return only one side's unmatched rows.
2fill in blank
medium

Complete the code to join orders and customers tables showing all orders and customers, matching by customer_id.

PostgreSQL
SELECT orders.id, customers.name FROM orders [1] customers ON orders.customer_id = customers.id;
Drag options to blanks, or click blank then click option'
ARIGHT JOIN
BFULL OUTER JOIN
CINNER JOIN
DLEFT JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN which excludes unmatched rows.
Using LEFT JOIN or RIGHT JOIN which exclude unmatched rows from one side.
3fill in blank
hard

Fix the error in the join clause to correctly perform a full outer join between products and sales.

PostgreSQL
SELECT products.name, sales.amount FROM products [1] sales ON products.id = sales.product_id;
Drag options to blanks, or click blank then click option'
AFULL OUTER JOIN
BLEFT OUTER JOIN
CFULL JOIN
DOUTER JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using OUTER JOIN without FULL, LEFT, or RIGHT.
Using LEFT OUTER JOIN which excludes unmatched rows from sales.
4fill in blank
hard

Fill both blanks to create a full outer join that shows all employees and their projects, matching by project_id.

PostgreSQL
SELECT employees.name, projects.title FROM employees [1] projects [2] employees.project_id = projects.id;
Drag options to blanks, or click blank then click option'
AFULL OUTER JOIN
BON
CWHERE
DUSING
Attempts:
3 left
💡 Hint
Common Mistakes
Using WHERE instead of ON for join condition.
Using USING when column names differ.
5fill in blank
hard

Fill all three blanks to write a full outer join query that selects employee names, department names, and handles unmatched rows.

PostgreSQL
SELECT employees.name AS employee_name, departments.name AS department_name FROM employees [1] departments [2] employees.dept_id = departments.id [3] employees.name IS NULL OR departments.name IS NULL;
Drag options to blanks, or click blank then click option'
AFULL OUTER JOIN
BON
CWHERE
DLEFT JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEFT JOIN which excludes unmatched rows from departments.
Using WHERE instead of ON for join condition.