0
0
SQLquery~20 mins

FULL OUTER JOIN behavior in SQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
FULL OUTER JOIN Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Output of FULL OUTER JOIN with partial matches

Consider two tables:

Employees
id | name
1 | Alice
2 | Bob
3 | Carol

Departments
id | dept_name
2 | Sales
3 | HR
4 | IT

What is the result of this query?

SELECT Employees.id, Employees.name, Departments.dept_name
FROM Employees
FULL OUTER JOIN Departments ON Employees.id = Departments.id
ORDER BY Employees.id NULLS LAST, Departments.id NULLS LAST;
SQL
SELECT Employees.id, Employees.name, Departments.dept_name
FROM Employees
FULL OUTER JOIN Departments ON Employees.id = Departments.id
ORDER BY Employees.id NULLS LAST, Departments.id NULLS LAST;
A
1 | Alice | NULL
2 | Bob | Sales
3 | Carol | HR
NULL | NULL | IT
B
1 | Alice | NULL
2 | Bob | Sales
3 | Carol | HR
C
2 | Bob | Sales
3 | Carol | HR
4 | NULL | IT
D
1 | Alice | NULL
2 | Bob | Sales
3 | Carol | HR
4 | NULL | IT
Attempts:
2 left
💡 Hint

FULL OUTER JOIN returns all rows from both tables, matching where possible, and NULL where no match exists.

🧠 Conceptual
intermediate
1:30remaining
Understanding NULLs in FULL OUTER JOIN results

When using FULL OUTER JOIN between two tables, which statement about NULL values in the result is true?

ANULLs appear only in columns from the left table when there is no match.
BNULLs appear only in columns from the right table when there is no match.
CNULLs never appear in FULL OUTER JOIN results.
DNULLs appear in columns from either table when there is no matching row in the other table.
Attempts:
2 left
💡 Hint

Think about what happens when a row exists in one table but not the other.

📝 Syntax
advanced
1:30remaining
Identify the syntax error in FULL OUTER JOIN query

Which of the following SQL queries will cause a syntax error?

SELECT A.id, B.name
FROM TableA A
FULL OUTER JOIN TableB B ON A.id = B.id
ASELECT A.id, B.name FROM TableA A FULL OUTER JOIN TableB B ON A.id = B.id;
BSELECT A.id, B.name FROM TableA A FULL JOIN TableB B ON A.id = B.id;
CSELECT A.id, B.name FROM TableA A OUTER FULL JOIN TableB B ON A.id = B.id;
DSELECT A.id, B.name FROM TableA A LEFT JOIN TableB B ON A.id = B.id;
Attempts:
2 left
💡 Hint

Check the order of keywords in the JOIN clause.

optimization
advanced
2:00remaining
Optimizing FULL OUTER JOIN queries for large tables

You have two large tables with millions of rows each. You want to perform a FULL OUTER JOIN on a key column. Which approach can improve query performance?

ACreate indexes on the join key columns in both tables before running the FULL OUTER JOIN.
BUse CROSS JOIN instead of FULL OUTER JOIN to get all combinations and filter later.
CRemove indexes on join keys to speed up the join operation.
DUse a subquery to select all rows from one table and then LEFT JOIN the other table.
Attempts:
2 left
💡 Hint

Indexes help the database find matching rows faster.

🔧 Debug
expert
2:30remaining
Diagnose unexpected NULLs in FULL OUTER JOIN result

You run this query:

SELECT A.id, A.value, B.value
FROM TableA A
FULL OUTER JOIN TableB B ON A.id = B.id
WHERE A.value > 10;

You notice that rows with NULL in A.value do not appear in the result. Why?

AThe WHERE clause filters after the FULL OUTER JOIN, so rows with NULL A.value pass the filter.
BThe condition A.value > 10 excludes rows where A.value is NULL, so those rows should not appear.
CThe WHERE clause filters before the FULL OUTER JOIN, so NULLs in A.value are ignored.
DThe FULL OUTER JOIN duplicates rows with NULL values in A.value.
Attempts:
2 left
💡 Hint

Think about when the WHERE clause is applied in relation to the JOIN.