SQL Interview Questions – Replace Employee ID With The Unique Identifier

Spread the love

Problem Description –

Write an SQL query to show the unique ID of each user, If a user does not have a unique ID replace just show null.

Return the result table in any order.

The query result format is in the following example.

Difficulty Level – Easy

Problem Link – Replace Employee ID

Solution –

SELECT
    unique_id,
    name
FROM (
SELECT
    e.id, 
    e.name,
    eu.unique_id
FROM EMployees as e LEFT JOIN EmployeeUNI as eu
ON e.id = eu.id
    ) x

Rating: 1 out of 5.

Leave a Reply