문제
Write a solution to report the products that were only sold in the first quarter of 2019. That is, between 2019-01-01 and 2019-03-31 inclusive.
Return the result table in any order.
"2019년 1분기에만 판매된 제품을 알 수 있는 쿼리를 작성해라 즉, 2019-01-01 부터 2019-03-01 사이에 포함된다."
문제 풀이
product_id 별로 날짜를 확인 해야 한다. 이때 중요하건 product_id 모두가 1분기 날짜에 팔려야 한다. 즉, 1개라도 1분기 날자 이후에 판매된 경우는 제외되어야 한다.
SELECT s.product_id
, p.product_name
FROM Sales AS s
LEFT JOIN Product AS p ON s.product_id = p.product_id
GROUP BY s.product_id
HAVING MIN(s.sale_date) >= '2019-01-01' AND MAX(s.sale_date)<='2019-03-31'
'취준 > 코팅 테스트' 카테고리의 다른 글
[LeetCode] - 1070.Product Sales Analysis 3 (0) | 2024.04.15 |
---|---|
[LeetCode] - 608. Tree Node (0) | 2024.04.10 |
[LeetCode] - 1965. Employees With Missing Information (0) | 2024.04.09 |
585. Investments in 2016 (0) | 2024.04.09 |
[LeetCode] - 1204. Last Person to Fit in the Bus (0) | 2024.04.06 |