-
leetcode - 1378. Replace Employee ID With The Unique IdentifierSQL 문제풀이 2022. 7. 8. 16:25
난이도 : Easy
Table: Employees
+---------------+---------+ | Column Name | Type | +---------------+---------+ | id | int | | name | varchar | +---------------+---------+ id is the primary key 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 for this table. Each row of this table contains the id and the corresponding unique id of an employee in the company.
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.
SELECT IFNULL(unique_id, null) unique_id , name FROM Employees LEFT JOIN EmployeeUNI ON EmployeeUNI.id = Employees.id
Accepted (36.42%)
'SQL 문제풀이' 카테고리의 다른 글
leetcode - 614. Second Degree Follower (0) 2022.07.08 leecode - 626. Exchange Seats (0) 2022.07.08 leecode - 1350. Students With Invalid Departments (0) 2022.07.08 leecode - 1327. List the Products Ordered in a Period (0) 2022.07.08 (Again) leecode - 612. Shortest Distance in a Plane (0) 2022.07.06