Attach Employee Identifiers without Dropping Unmatched Employees

Quick Overview

Return every employee with all of their recorded identifier mappings, using NULL when no mapping exists.

Attach Employee Identifiers without Dropping Unmatched Employees

Company: Google

Role: Software Engineer

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

### Problem Return unique_id and name for every Employees row. Match EmployeeUNI by id; show NULL when no identifier mapping exists. An employee with several matching identifier rows contributes one result per identifier. Result row order is unrestricted. ### Tables Table: `Employees` ```text +---------------+---------+ | Column Name | Type | +---------------+---------+ | id | int | | name | varchar | +---------------+---------+ id is the primary key (column with unique values) for this table. Each row of this table contains the id and the name of an employee in a company. ``` Table: `EmployeeUNI` ```text +---------------+---------+ | Column Name | Type | +---------------+---------+ | id | int | | unique_id | int | +---------------+---------+ (id, unique_id) is the primary key (combination of columns with unique values) for this table. Each row of this table contains the id and the corresponding unique id of an employee in the company. ``` ### Example ```text Employees (id,name): (1,Ada), (2,Bo), (3,Cam) EmployeeUNI (id,unique_id): (2,8), (2,11), (3,9) Output (unique_id,name): (NULL,Ada), (8,Bo), (11,Bo), (9,Cam) ``` ### What a Strong Answer Covers - Retain every employee, including those without an identifier. - Return all matching identifier rows, since the key contains both columns. ### Follow-up Questions - How would the result change if the business allowed just one identifier per employee? - How would you find mappings that refer to a missing employee?

Overview: Return every employee with all of their recorded identifier mappings, using NULL when no mapping exists.

Google logo
Google
easySoftware EngineerOtherData Manipulation (SQL/Python)
0
0

Problem

Return unique_id and name for every Employees row. Match EmployeeUNI by id; show NULL when no identifier mapping exists. An employee with several matching identifier rows contributes one result per identifier. Result row order is unrestricted.

Tables

Table: Employees

+---------------+---------+
| Column Name   | Type    |
+---------------+---------+
| id            | int     |
| name          | varchar |
+---------------+---------+
id is the primary key (column with unique values) for this table.
Each row of this table contains the id and the name of an employee in a company.

Table: EmployeeUNI

+---------------+---------+
| Column Name   | Type    |
+---------------+---------+
| id            | int     |
| unique_id     | int     |
+---------------+---------+
(id, unique_id) is the primary key (combination of columns with unique values) for this table.
Each row of this table contains the id and the corresponding unique id of an employee in the company.

Example

Employees (id,name): (1,Ada), (2,Bo), (3,Cam)
EmployeeUNI (id,unique_id): (2,8), (2,11), (3,9)
Output (unique_id,name): (NULL,Ada), (8,Bo), (11,Bo), (9,Cam)

What a Strong Answer Covers Guidance

  • Retain every employee, including those without an identifier.
  • Return all matching identifier rows, since the key contains both columns.

Follow-up Questions Guidance

  • How would the result change if the business allowed just one identifier per employee?
  • How would you find mappings that refer to a missing employee?