Notice
Recent Posts
Recent Comments
Link
복's
[ LeetCode - 175 ] Combine Two Tables 본문
728x90
https://leetcode.com/problems/combine-two-tables/description/
Combine Two Tables - LeetCode
Can you solve this real interview question? Combine Two Tables - Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | personId | int | | lastName | varchar | | firstName | varchar | +-------------+---------+ personId i
leetcode.com
LeetCode에 SQL 문제도 있었다 !!!
진짜 오랜만에 쿼리도 쳐보는 것 같다.
앞으로 시간만 된다면 한 문제씩 푸는 것도 나쁘지 않을 거 같고, 그리고 덤으로 다른 사람들 쿼리도 볼 수 있으니 초보자인 나에게 좋은 연습이 될 거 같다.
정글 와서는 NoSql이랑 ORM, ODM만 사용해서 오랜만에 하니까 색다르네
[ 📌 풀이 ]
예시 보면 Address 테이블에 Allen에 대한 정보가 없음에도 출력이 되었기 때문에 inner가 아닌 outer join을 이용해서 문제를 풀었다.
[ 📌 코드 - Oracle ]
select p.firstName
, p.lastName
, a.city
, a.state
from Person p
left outer join Address a
on p.personID = a.personId
[ 📌 결과 - Oracle ]
다른 사람들 풀이도 똑같은데 속도는 답안 제출때 마다 다른 것 같다
728x90
'알고리즘 > LeetCode' 카테고리의 다른 글
[ LeetCode - 181 ] Employees Earning More Than Their Managers (0) | 2023.11.12 |
---|---|
[ LeetCode - 94 ] Binary Tree Inorder Traversal (0) | 2023.11.12 |
[ LeetCode - 88 ] Merge Sorted Array (0) | 2023.11.11 |
[ LeetCode - 83 ] Remove Duplicates from Sorted List (0) | 2023.11.08 |
[ LeetCode - 69 ] Sqrt(x) (0) | 2023.11.05 |