728x90
https://leetcode.com/problems/combine-two-tables/
Combine Two Tables - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
[problem]
두 테이블간의 join 필요
Write an SQL query to report the first name, last name, city, and state of each person in the Person table. If the address of a personId is not present in the Address table, report null instead.
Return the result table in any order.

[analysis]
1. address가 null인 경우도 정보를 보여줘야 하므로 person table 기준으로 left join 실행
2. 두 테이블에 공통 컬럼인 personId 기준으로 join
[solution]

728x90
'MS SQL > MS SQL : Leetcode' 카테고리의 다른 글
| SQL - 586. Customer Placing the Largest Number of Orders (select, count) (0) | 2022.04.26 |
|---|---|
| SQL - 511. Game Play Analysis I (min, group by) (0) | 2022.04.26 |
| SQL - 183. Customers Who Never Order (left join, where) (0) | 2022.04.26 |
| SQL - Leetcode 620. Not Boring Movies (where, order by) (0) | 2022.04.25 |
| SQL - Leetcode 182.duplicate-emails (group by, having) (0) | 2022.04.25 |