Challenge - 5 Problems
SQL Joins Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding INNER JOIN behavior
Given two tables, Employees and Departments, what will be the result of an INNER JOIN on the department ID if some employees do not belong to any department?
DBMS Theory
SELECT Employees.name, Departments.name FROM Employees INNER JOIN Departments ON Employees.dept_id = Departments.id;
Attempts:
2 left
💡 Hint
Think about what INNER JOIN does when there is no matching record in the other table.
✗ Incorrect
INNER JOIN returns only rows where there is a match in both tables. Employees without a department will be excluded.
📋 Factual
intermediate2:00remaining
Identifying LEFT JOIN output
What does a LEFT JOIN return when joining Customers with Orders on customer ID, if some customers have no orders?
DBMS Theory
SELECT Customers.name, Orders.order_id FROM Customers LEFT JOIN Orders ON Customers.id = Orders.customer_id;
Attempts:
2 left
💡 Hint
LEFT JOIN keeps all rows from the left table regardless of matches.
✗ Incorrect
LEFT JOIN returns all rows from the left table (Customers). If no matching order exists, order columns are NULL.
🔍 Analysis
advanced2:00remaining
Determining output of FULL OUTER JOIN
Consider two tables: Authors and Books. What will a FULL OUTER JOIN on author ID return if some authors have no books and some books have no authors?
DBMS Theory
SELECT Authors.name, Books.title FROM Authors FULL OUTER JOIN Books ON Authors.id = Books.author_id;
Attempts:
2 left
💡 Hint
FULL OUTER JOIN combines LEFT and RIGHT JOIN results.
✗ Incorrect
FULL OUTER JOIN returns all rows from both tables. Where no match exists, NULL fills the missing side.
❓ Comparison
advanced2:00remaining
Comparing CROSS JOIN and INNER JOIN
What is the main difference between a CROSS JOIN and an INNER JOIN when joining two tables without any ON condition?
DBMS Theory
SELECT * FROM TableA CROSS JOIN TableB; SELECT * FROM TableA INNER JOIN TableB;
Attempts:
2 left
💡 Hint
Think about the requirement of ON clause in INNER JOIN.
✗ Incorrect
INNER JOIN requires an ON condition to match rows. Without it, the query is invalid. CROSS JOIN returns all combinations.
❓ Reasoning
expert2:00remaining
Predicting number of rows after multiple joins
Given three tables: Students (10 rows), Enrollments (15 rows), and Courses (5 rows). Enrollments links Students and Courses by IDs. If you perform an INNER JOIN of Students to Enrollments, then INNER JOIN the result to Courses, how many rows will the final result have?
DBMS Theory
SELECT Students.name, Courses.title FROM Students INNER JOIN Enrollments ON Students.id = Enrollments.student_id INNER JOIN Courses ON Enrollments.course_id = Courses.id;
Attempts:
2 left
💡 Hint
Enrollments represent each student-course pair; joins filter to matching pairs.
✗ Incorrect
The join chains filter to enrollments linking students and courses. The final row count matches enrollments (15).