File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed
Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ Have a good contributing!
4848 - [ 619. Biggest Single Number] ( ./leetcode/easy/619.%20Biggest%20Single%20Number.sql )
4949 - [ 620. Not Boring Movies] ( ./leetcode/easy/620.%20Not%20Boring%20Movies.sql )
5050 - [ 1068. Product Sales Analysis I] ( ./leetcode/easy/1068.%20Product%20Sales%20Analysis%20I.sql )
51+ - [ 1327. List the Products Ordered in a Period] ( ./leetcode/easy/1327.%20List%20the%20Products%20Ordered%20in%20a%20Period.sql )
5152 - [ 1407. Top Travellers] ( ./leetcode/easy/1407.%20Top%20Travellers.sql )
5253 - [ 1484. Group Sold Products By The Date] ( ./leetcode/easy/1484.%20Group%20Sold%20Products%20By%20The%20Date.sql )
5354 - [ 1587. Bank Account Summary II] ( ./leetcode/easy/1587.%20Bank%20Account%20Summary%20II.sql )
Original file line number Diff line number Diff line change 1+ /*
2+ Question 1327. List the Products Ordered in a Period
3+ Link: https://leetcode.com/problems/list-the-products-ordered-in-a-period/description/
4+
5+ Table: Products
6+
7+ +------------------+---------+
8+ | Column Name | Type |
9+ +------------------+---------+
10+ | product_id | int |
11+ | product_name | varchar |
12+ | product_category | varchar |
13+ +------------------+---------+
14+ product_id is the primary key (column with unique values) for this table.
15+ This table contains data about the company's products.
16+
17+
18+ Table: Orders
19+
20+ +---------------+---------+
21+ | Column Name | Type |
22+ +---------------+---------+
23+ | product_id | int |
24+ | order_date | date |
25+ | unit | int |
26+ +---------------+---------+
27+ This table may have duplicate rows.
28+ product_id is a foreign key (reference column) to the Products table.
29+ unit is the number of products ordered in order_date.
30+
31+
32+ Write a solution to get the names of products that have at least 100 units ordered in February 2020 and their amount.
33+
34+ Return the result table in any order.
35+ */
36+
37+ SELECT
38+ p .product_name ,
39+ SUM (o .unit ) as unit -- noqa: CP01
40+ FROM Orders AS o
41+ LEFT JOIN
42+ Products AS p
43+ ON o .product_id = p .product_id
44+ WHERE o .order_date BETWEEN ' 2020-02-01' AND ' 2020-02-29'
45+ GROUP BY p .product_name
46+ HAVING SUM (o .unit ) >= 100
You can’t perform that action at this time.
0 commit comments