|
1 | | ---1378. Replace Employee ID With The Unique Identifier |
2 | | --- |
3 | | ---Table: Employees |
4 | | --- |
5 | | ---+---------------+---------+ |
6 | | ---| Column Name | Type | |
7 | | ---+---------------+---------+ |
8 | | ---| id | int | |
9 | | ---| name | varchar | |
10 | | ---+---------------+---------+ |
11 | | ---id is the primary key for this table. |
12 | | ---Each row of this table contains the id and the name of an employee in a company. |
13 | | --- |
14 | | --- |
15 | | ---Table: EmployeeUNI |
16 | | --- |
17 | | ---+---------------+---------+ |
18 | | ---| Column Name | Type | |
19 | | ---+---------------+---------+ |
20 | | ---| id | int | |
21 | | ---| unique_id | int | |
22 | | ---+---------------+---------+ |
23 | | ---(id, unique_id) is the primary key for this table. |
24 | | ---Each row of this table contains the id and the corresponding unique id of an employee in the company. |
25 | | --- |
26 | | --- |
27 | | ---Write an SQL query to show the unique ID of each user, If a user doesn't have a unique ID replace just show null. |
28 | | --- |
29 | | ---Return the result table in any order. |
30 | | --- |
31 | | ---The query result format is in the following example: |
32 | | --- |
33 | | ---Employees table: |
34 | | ---+----+----------+ |
35 | | ---| id | name | |
36 | | ---+----+----------+ |
37 | | ---| 1 | Alice | |
38 | | ---| 7 | Bob | |
39 | | ---| 11 | Meir | |
40 | | ---| 90 | Winston | |
41 | | ---| 3 | Jonathan | |
42 | | ---+----+----------+ |
43 | | --- |
44 | | ---EmployeeUNI table: |
45 | | ---+----+-----------+ |
46 | | ---| id | unique_id | |
47 | | ---+----+-----------+ |
48 | | ---| 3 | 1 | |
49 | | ---| 11 | 2 | |
50 | | ---| 90 | 3 | |
51 | | ---+----+-----------+ |
52 | | --- |
53 | | ---EmployeeUNI table: |
54 | | ---+-----------+----------+ |
55 | | ---| unique_id | name | |
56 | | ---+-----------+----------+ |
57 | | ---| null | Alice | |
58 | | ---| null | Bob | |
59 | | ---| 2 | Meir | |
60 | | ---| 3 | Winston | |
61 | | ---| 1 | Jonathan | |
62 | | ---+-----------+----------+ |
63 | | --- |
64 | | ---Alice and Bob don't have a unique ID, We will show null instead. |
65 | | ---The unique ID of Meir is 2. |
66 | | ---The unique ID of Winston is 3. |
67 | | ---The unique ID of Jonathan is 1. |
68 | | --- |
69 | 1 | --# Write your MySQL query statement below |
70 | 2 |
|
71 | 3 | select uni.unique_id, emp.name from Employees emp |
|
0 commit comments