[ORACLE_SQL](LEET_CODE)1378. Replace Employee ID With The Unique Identifier

이경영·2023년 8월 7일
0

오라클

목록 보기
36/43

https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier/description/?envType=study-plan-v2&envId=top-sql-50

문제요약

employeeuni 테이블의 unique_id가 존재하면
output에 unique_id를 쓰고,
아닐경우에는 null로 처리. 전형적인 left join, right join의 문제

핵심포인트

join(left, right)

방법

두 id를 join 한뒤, 다 나와야 하는 테이블을 결정한다.
name값은 다 결과가 나와있기 때문에 이를 기준 테이블로 설정하고 id를 기준으로 join한다.

정답

select a.unique_id, b.name 
from employeeuni a right join employees b
on a.id=b.id
profile
꾸준히

1개의 댓글

comment-user-thumbnail
2023년 8월 7일

글 잘 봤습니다.

답글 달기