반응형
https://leetcode.com/problems/sales-analysis-iii/description/
join과 group by를 사용해본 문제였습니다.
📕 풀이방법
📔 풀이과정
sales과 product table을 join 후에 봄에 팔린 적이 없는 product_id, product_name을 select해줍니다.
📕 Code
📔 ANSI SQL
select p.product_id, p.product_name from sales s
join product p
on p.product_id = s.product_id
group by p.product_id
having sum(case when s.sale_date not between '2019-01-01' and '2019-03-31' then 1 else 0 end) = 0
*더 나은 내용을 위한 지적, 조언은 언제나 환영합니다.
'SQL' 카테고리의 다른 글
(SQL) - LeetCode (easy) 1280. Students and Examinations (0) | 2024.01.12 |
---|---|
(SQL) - LeetCode (easy) 1179. Reformat Department Table (1) | 2023.11.22 |
(SQL) - LeetCode (easy) 1075. Project Employees I (0) | 2023.10.24 |
(SQL) - LeetCode (easy) 627. Swap Salary (0) | 2023.05.25 |
(SQL) - LeetCode (easy) 619. Biggest Single Number (0) | 2023.05.22 |