Interview Questions/SQL/Replace Employee ID with Unique Identifier

Replace Employee ID with Unique Identifier

Preview mode. Log in to edit, run, submit, and save progress.

Medium

Replace Employee ID with Unique Identifier

You have two tables: Employees and EmployeeUNI. Each employee has an id and a name. Some employees have been assigned a unique_id in the EmployeeUNI table, but not all. Write a SQL query to show the unique_id and name of each employee. If an employee does not have a unique_id, show NULL instead. Return the result in any order. (id, unique_id) is the primary key of EmployeeUNI.

Examples

Example 1

Alice and Bob have no unique_id - show NULL. Meir → 2, Winston → 3, Jonathan → 1.

Approach hint

Start with a simple approach, explain the trade-off, then move toward a cleaner or more scalable solution.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

query.sql