Row count of a left join with unmatched rows

The tables below come from a small company database, where each employee belongs to at most one department.


departments


dept_id

name

10

Sales

20

Research

30

Legal

40

Support


employees


emp_id

name

dept_id

1

Ava

10

2

Raj

10

3

Kim

20

4

Leo

10

5

Zoe

NULL

6

Sam

20


How many rows does the following query return? Give your answer as a whole number.


SQL
SELECT d.name AS department, e.name AS employee
FROM departments d
LEFT JOIN employees e ON d.dept_id = e.dept_id;

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Multiple Table Queries Questions: