# 문제
https://leetcode.com/problems/list-the-products-ordered-in-a-period/description/
# 문제 요약

2월 동안 100개 이상으로 팔린 제품이름과 수량 출력하기
# 정답 코드
with cte as (
select p.product_id, p.product_name, p.product_category, o.order_date, o.unit
from Products p
inner join Orders o
on p.product_id = o.product_id
where o.order_date >= '2020-02-01' and o.order_date < '2020-03-01'
), cte2 as (
select product_name,
sum(unit) as unit
from cte
group by product_name
having sum(unit) >= 100
)
select *
from cte2'Algorithm🐤 > SQL' 카테고리의 다른 글
| [프로그래머스] 이름에 el이 들어가는 동물 찾기 - LOWER() / UPPER() (0) | 2024.08.09 |
|---|---|
| [SQL] 프로그래머스 다시 처음부터 복습 (1번~12번) (0) | 2024.08.08 |
| [리트코드] 1484. Group Sold Products By The Date - group_concat()✔️✔️✔️ (0) | 2024.07.17 |
| [리트코드] 196. Delete Duplicate Emails - 델프웨(delete / from / where) (0) | 2024.07.17 |
| [리트코드] 1527. Patients with a Conditions - like '% 글자%', substring_index(문자열, ',', 4) (1) | 2024.07.16 |