0
0
SQLquery~20 mins

INNER JOIN with ON condition in SQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
INNER JOIN Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
INNER JOIN with simple ON condition
Given two tables Employees and Departments, what is the result of the following query?
SQL
SELECT Employees.Name, Departments.DepartmentName FROM Employees INNER JOIN Departments ON Employees.DepartmentID = Departments.ID;
A[{"Name": "Alice", "DepartmentName": "HR"}, {"Name": "Bob", "DepartmentName": "Finance"}]
B[]
C[{"Name": "Alice"}, {"Name": "Bob"}]
D[{"Name": "Alice", "DepartmentName": "HR"}, {"Name": "Bob", "DepartmentName": "IT"}]
Attempts:
2 left
💡 Hint
Think about matching DepartmentID in Employees with ID in Departments.
📝 Syntax
intermediate
2:00remaining
Identify the syntax error in INNER JOIN
Which option contains a syntax error in the INNER JOIN statement?
SQL
SELECT * FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID;
ASELECT * FROM Orders INNER JOIN Customers Orders.CustomerID = Customers.ID;
BSELECT * FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID WHERE Orders.Amount > 100;
CSELECT * FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID;
DSELECT * FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID ORDER BY Customers.Name;
Attempts:
2 left
💡 Hint
Check for missing keywords or clauses in the JOIN syntax.
optimization
advanced
2:00remaining
Optimizing INNER JOIN with multiple conditions
Which query is the most efficient way to join Sales and Products tables on both ProductID and Region?
ASELECT * FROM Sales INNER JOIN Products ON Sales.ProductID = Products.ID WHERE Sales.Region = Products.Region;
BSELECT * FROM Sales INNER JOIN Products ON Sales.ProductID = Products.ID AND Sales.Region = Products.Region;
CSELECT * FROM Sales, Products WHERE Sales.ProductID = Products.ID AND Sales.Region = Products.Region;
DSELECT * FROM Sales INNER JOIN Products USING (ProductID, Region);
Attempts:
2 left
💡 Hint
Consider how join conditions affect query execution and filtering.
🧠 Conceptual
advanced
2:00remaining
Understanding INNER JOIN behavior with NULL values
What happens when you INNER JOIN two tables on a column that contains NULL values in one table?
ARows with NULL in the join column are excluded from the result.
BRows with NULL in the join column are included with NULLs in the joined columns.
CThe query returns an error due to NULL values in join columns.
DRows with NULL in the join column are matched with all rows in the other table.
Attempts:
2 left
💡 Hint
Think about how NULL compares in SQL join conditions.
🔧 Debug
expert
2:00remaining
Debugging unexpected INNER JOIN results
You run this query but get fewer rows than expected: SELECT Orders.OrderID, Customers.Name FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID WHERE Customers.Country = 'USA'; What is the most likely reason?
AINNER JOIN does not work with WHERE clauses.
BThe WHERE clause filters out all rows because no Customers are from USA.
CSome Orders have CustomerID values that do not exist in Customers table.
DThe ON condition is incorrect; it should use Orders.ID = Customers.CustomerID.
Attempts:
2 left
💡 Hint
Consider how INNER JOIN and WHERE filtering interact.