Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
SQL Joins for Calibration Logs
00:00
5 left

SQL Joins for Calibration Logs

HardSQL · PostgreSQL

Problem

Hexagon Ab needs a staffing view for active products such as HxDR and HxGN EAM. Write a PostgreSQL query that lists every active project, assigned employees, and each employee's manager.

Requirements

  1. Use a RIGHT OUTER JOIN so active projects remain in the result even when they have no staffing assignment.
  2. Use LEFT OUTER JOIN to retain assignments whose employee is currently unknown.
  3. Use a self-join on employees to resolve each employee's manager.
  4. Return project code, project name, employee name, manager name, and allocation percentage, ordered by project code and employee name, with unassigned rows last.

Schema

employees
ColumnTypeDescription
employee_idPKINTEmployee identifier
employee_nameVARCHAR(100)Employee's full name
manager_idINTEmployee ID of the manager
departmentVARCHAR(80)Employee department
employee_projects
ColumnTypeDescription
assignment_idPKINTAssignment identifier
employee_idINTAssigned employee
project_idINTAssigned project
allocation_pctINTPercentage of working time allocated
projects
ColumnTypeDescription
project_idPKINTProject identifier
project_codeVARCHAR(30)Project or product code
project_nameVARCHAR(150)Project or product name
statusVARCHAR(20)Project lifecycle status
Tablesemployeesemployee_projectsprojects
Interviewer

Your question is SQL Joins for Calibration Logs. Start with the requirements and the three 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.