안녕하세요!
이번 포스팅은 LeetCode에 있는 List the Products Ordered in a Period 문제를 OracleDB로 풀어보려고 합니다!
(모든 문제는 Oracle로 풀이하겠습니다.)
1. 문제 링크 : https://leetcode.com/problems/list-the-products-ordered-in-a-period/description/
2. 문제
| Column name | Type |
| product_id | int |
| product_name | varchar |
| product_category | varchar |
| Column name | Type |
| product_id | int |
| order_date | date |
| unit | int |
[문제] Write a solution to get the names of products that have at least 100 units ordered in February 2020 and their amount.
2020년 2월에 최소 100개 이상 주문된 제품의 이름과 수량을 조회하는 문제입니다.
3. 제출 쿼리 및 설명
최종) 2020년 2월에 최소 100개 이상 주문된 제품의 이름과 수량을 조회합니다.
SELECT P.PRODUCT_NAME, SUM(UNIT) AS UNIT
FROM PRODUCTS P, ORDERS O
WHERE P.PRODUCT_ID = O.PRODUCT_ID
AND TO_CHAR(ORDER_DATE, 'YYYY-MM') = '2020-02'
GROUP BY P.PRODUCT_NAME
HAVING SUM(UNIT) >= 100
;
'SQL > LeetCode' 카테고리의 다른 글
| [SQL] Capital Gain/Loss(LeetCode/Oracle) (0) | 2023.10.26 |
|---|---|
| [SQL] Movie Rating(LeetCode/Oracle) (0) | 2023.10.23 |
| [SQL] Restaurant Growth(LeetCode/Oracle) (1) | 2023.10.23 |
| [SQL] Students and Examinations(LeetCode/Oracle) (0) | 2023.10.23 |
| [SQL] Average Selling Price(LeetCode/Oracle) (1) | 2023.10.20 |