Map Employee Codes to Unique Identifiers

Quick Overview

Write a SQL query that lists every employee's name next to their unique identifier, matched on employee code, and shows NULL for employees who have none. It tests outer joins, how unmatched rows are kept, and how one-to-many matches multiply rows.

Map Employee Codes to Unique Identifiers

Company: Point72

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

For each employee, return `unique_identifier` and `emp_name`, matching on `emp_code`. If an employee has no unique identifier, show `NULL`. ```hint Check the example Look at what happens to the employees without an identifier under each kind of join. ``` ### Input Table(s) Table `employee_info`, primary key `emp_code`. Each row holds the code and name of one employee in the organization. | Column | Type | Meaning | |---|---|---| | emp_code | INT | Employee code, unique per employee | | emp_name | VARCHAR | Employee name | Table `unique_identifiers`, primary key `(emp_code, unique_identifier)`. Each row holds an employee code and a unique identifier assigned to that employee. | Column | Type | Meaning | |---|---|---| | emp_code | INT | Employee code | | unique_identifier | INT | Identifier assigned to that employee | ### Output Contract Return exactly these columns, in this order: | Column | Type | Meaning | |---|---|---| | unique_identifier | INT | The employee's identifier, or `NULL` when the employee has none | | emp_name | VARCHAR | The employee's name | Sort the rows by `emp_code` ascending (the column is not returned), then by `unique_identifier` ascending. No rounding applies. ### Example `employee_info`: | emp_code | emp_name | |---|---| | 101 | Priya | | 102 | Marcus | | 103 | Elena | | 104 | Tomas | `unique_identifiers`: | emp_code | unique_identifier | |---|---| | 101 | 5001 | | 103 | 5003 | | 103 | 5017 | | 105 | 5005 | Expected result: | unique_identifier | emp_name | |---|---| | 5001 | Priya | | NULL | Marcus | | 5003 | Elena | | 5017 | Elena | | NULL | Tomas | Marcus and Tomas have no identifier, so each appears once with `NULL`. Elena has two identifiers and appears once for each. The row for code 105 matches no employee and is not returned. ### Constraints and Clarifications - Every employee in `employee_info` appears in the result at least once. - An employee with several identifiers appears once per identifier. An employee with none appears exactly once, with `NULL` in `unique_identifier`. - Rows in `unique_identifiers` whose `emp_code` matches no employee are ignored. - `unique_identifier` is never `NULL` in the source table, so a `NULL` in the result always means the employee has no identifier. - Two employees can share a name. They are still separate employees and each gets their own rows.

Overview: Write a SQL query that lists every employee's name next to their unique identifier, matched on employee code, and shows NULL for employees who have none. It tests outer joins, how unmatched rows are kept, and how one-to-many matches multiply rows.

Point72 logo
Point72
Nov 24, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

For each employee, return unique_identifier and emp_name, matching on emp_code. If an employee has no unique identifier, show NULL.

Input Table(s)

Table employee_info, primary key emp_code. Each row holds the code and name of one employee in the organization.

ColumnTypeMeaning
emp_codeINTEmployee code, unique per employee
emp_nameVARCHAREmployee name

Table unique_identifiers, primary key (emp_code, unique_identifier). Each row holds an employee code and a unique identifier assigned to that employee.

ColumnTypeMeaning
emp_codeINTEmployee code
unique_identifierINTIdentifier assigned to that employee

Output Contract

Return exactly these columns, in this order:

ColumnTypeMeaning
unique_identifierINTThe employee's identifier, or NULL when the employee has none
emp_nameVARCHARThe employee's name

Sort the rows by emp_code ascending (the column is not returned), then by unique_identifier ascending. No rounding applies.

Example

employee_info:

emp_codeemp_name
101Priya
102Marcus
103Elena
104Tomas

unique_identifiers:

emp_codeunique_identifier
1015001
1035003
1035017
1055005

Expected result:

unique_identifieremp_name
5001Priya
NULLMarcus
5003Elena
5017Elena
NULLTomas

Marcus and Tomas have no identifier, so each appears once with NULL. Elena has two identifiers and appears once for each. The row for code 105 matches no employee and is not returned.

Constraints and Clarifications

  • Every employee in employee_info appears in the result at least once.
  • An employee with several identifiers appears once per identifier. An employee with none appears exactly once, with NULL in unique_identifier .
  • Rows in unique_identifiers whose emp_code matches no employee are ignored.
  • unique_identifier is never NULL in the source table, so a NULL in the result always means the employee has no identifier.
  • Two employees can share a name. They are still separate employees and each gets their own rows.