#506 Employee Unique ID

Companies:
Sberbank
Themes:
SQLJoinsPractice

Write a query that displays the unique_id for every user.

If an employee has no record in the EmployeeUNI table, output null instead of unique_id.

CREATE TABLE Employees (
    id INTEGER PRIMARY KEY,
    name VARCHAR NOT NULL
);

CREATE TABLE EmployeeUNI (
    id INTEGER PRIMARY KEY,
    unique_id INTEGER
);

INSERT INTO Employees VALUES (1, 'Alice');
INSERT INTO Employees VALUES (7, 'Bob');
INSERT INTO Employees VALUES (11, 'Meir');
INSERT INTO Employees VALUES (90, 'Winston');
INSERT INTO Employees VALUES (3, 'Jonathan');

INSERT INTO EmployeeUNI VALUES (3, 1);
INSERT INTO EmployeeUNI VALUES (11, 2);
INSERT INTO EmployeeUNI VALUES (90, 3);

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in