[코드카타] SQL 63 List the Products Ordered in a Period

Data_Student·2024년 12월 11일
0

코드카타

목록 보기
73/82

[코드카타] SQL 63 List the Products Ordered in a Period

63. List the Products Ordered in a Period
https://leetcode.com/problems/list-the-products-ordered-in-a-period/

Write a solution to get the names of products that have at least 100 units 
ordered in February 2020 and their amount.
Return the result table in any order.
Select product_name, sum(unit) unit
From Products p join Orders o 
on p.product_id=o.product_id and o.order_date like '2020-02%'
group by p.product_id
having sum(unit) >= 100
이전 문제들보다 상당히 빠르게 풀이 완료
이번 문제가 쉬웠던 건지 익숙한 건지 모르겠지만 직관적이었던건 확실한 느낌
참고로 beats가 99.86% 까지 나옴

0개의 댓글