Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Find Employees With Managers

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Find Employees With Managers. Start with the requirements and the one table on the right.

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.

Problem

NiCE uses employee hierarchy data to support administration and workforce workflows in NiCE CXone. Write a PostgreSQL query that lists every employee and, when available, the employee's direct manager.

Requirements

  1. Return every employee, including employees who do not have a manager.
  2. Display the employee's ID and name, plus the manager's ID and name.
  3. Use a self-join with a LEFT JOIN, and sort the result alphabetically by employee name.

Schema

employees
ColumnTypeDescription
employee_idPKINTEGERUnique employee identifier
employee_nameVARCHAR(100)Employee's full name
manager_idINTEGERReferences employees.employee_id for the direct manager
job_titleVARCHAR(100)Employee's job title
departmentVARCHAR(100)Organizational department
hire_dateDATEEmployee's hire date
Tablesemployees
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results