🤔 문제 분석
1) Write an SQL query that reports the products that were only sold in the first quarter of 2019.
That is, between 2019-01-01 and 2019-03-31 inclusive.
💡 풀이
SELECT DISTINCT S.product_id, P.product_name
FROM Sales AS S
INNER JOIN Product AS P ON S.product_id = P.product_id
WHERE S.product_id NOT IN (SELECT Sales.product_id
FROM Sales
INNER JOIN Product ON Sales.product_id = Product.product_id
WHERE sale_date NOT BETWEEN "2019-01-01" AND "2019-03-31")
'코딩테스트 > 리트코드 SQL' 카테고리의 다른 글
[리트코드/SQL] 32. Bank Account Summary II (1587) (0) | 2023.02.14 |
---|---|
[리트코드/SQL] 31. Actors and Directors Who Cooperated At Least Three Times (1050) (0) | 2023.02.14 |
[리트코드/SQL] 30. Duplicate Emalis (182) (0) | 2022.12.23 |
[리트코드/SQL] 28. Top Travellers (1407) (0) | 2022.12.23 |
[리트코드/SQL] 27. Capital Gain/Loss(1393) (0) | 2022.12.21 |
댓글