Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Join Employees and Departments
00:00
5 left

Join Employees and Departments

EasySQL · PostgreSQL

Problem

Join Employees with Departments and display name and department.

Asked in the technical stage. This was a live SQL round using a given Employees/Departments schema; the candidate shared their screen, ran the query, and pasted the output in chat.

Output

  1. Return one row per employee with columns name and department.
  2. Include employees without an assigned department, displaying Unassigned for the department.
  3. Order by employee name ascending, then employee ID ascending for ties.

Schema

employees
ColumnTypeDescription
employee_idPKINTUnique employee identifier
employee_nameVARCHAR(100)Employee's full name
department_idINTAssigned department identifier
departments
ColumnTypeDescription
department_idPKINTUnique department identifier
department_nameVARCHAR(100)Department name
Tablesemployeesdepartments
Interviewer

Your question is Join Employees and Departments. Start with the requirements and the two tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.