Bird
0
0

Given tables Employees (id, name) and Sales (emp_id, amount), what will this query return? SELECT Employees.name, Sales.amount FROM Employees LEFT OUTER JOIN Sales ON Employees.id = Sales.emp_id;

medium📝 query result Q4 of 15
SQL - LEFT and RIGHT JOIN
Given tables Employees (id, name) and Sales (emp_id, amount), what will this query return? SELECT Employees.name, Sales.amount FROM Employees LEFT OUTER JOIN Sales ON Employees.id = Sales.emp_id;
AAll sales records with employee names; NULL if no employee
BOnly employees who have sales records
COnly sales records with matching employees
DAll employees with their sales amounts; NULL if no sales
Step-by-Step Solution
Solution:
  1. Step 1: Analyze LEFT OUTER JOIN effect

    LEFT OUTER JOIN keeps all rows from Employees and matches Sales; unmatched Sales show NULL.
  2. Step 2: Understand result columns

    Employees.name always present; Sales.amount NULL if no matching sale.
  3. Final Answer:

    All employees with their sales amounts; NULL if no sales -> Option D
  4. Quick Check:

    LEFT OUTER JOIN returns all left rows with NULLs for unmatched right [OK]
Quick Trick: LEFT OUTER JOIN keeps all left table rows with NULLs for no match [OK]
Common Mistakes:
MISTAKES
  • Expecting only matched rows
  • Confusing left and right table roles
  • Assuming NULLs are filtered out

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes