1327. List the Products Ordered in a Period LeetCode Solution
In this guide, you will get 1327. List the Products Ordered in a Period LeetCode Solution with the best time and space complexity. The solution to List the Products Ordered in a Period problem is provided in various programming languages like C++, Java, and Python. This will be helpful for you if you are preparing for placements, hackathons, interviews, or practice purposes. The solutions provided here are very easy to follow and include detailed explanations.
Table of Contents
- Problem Statement
- Complexity Analysis
- List the Products Ordered in a Period solution in C++
- List the Products Ordered in a Period solution in Java
- List the Products Ordered in a Period solution in Python
- Additional Resources
Problem Statement of List the Products Ordered in a Period
Table: Products
+——————+———+
| Column Name | Type |
+——————+———+
| product_id | int |
| product_name | varchar |
| product_category | varchar |
+——————+———+
product_id is the primary key (column with unique values) for this table.
This table contains data about the company’s products.
Table: Orders
+—————+———+
| Column Name | Type |
+—————+———+
| product_id | int |
| order_date | date |
| unit | int |
+—————+———+
This table may have duplicate rows.
product_id is a foreign key (reference column) to the Products table.
unit is the number of products ordered in order_date.
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.
The result format is in the following example.
Example not found
Constraints not found
Complexity Analysis
- Time Complexity: Google AdSense
- Space Complexity: Google Analytics
1327. List the Products Ordered in a Period LeetCode Solution in C++
SELECT
Products.product_name,
SUM(Orders.unit) AS unit
FROM Products
INNER JOIN Orders
USING (product_id)
WHERE DATE_FORMAT(Orders.order_date, '%Y-%m') = '2020-02'
GROUP BY product_id
HAVING SUM(Orders.unit) >= 100;
/* code provided by PROGIEZ */
1327. List the Products Ordered in a Period LeetCode Solution in Java
N/A
// code provided by PROGIEZ
1327. List the Products Ordered in a Period LeetCode Solution in Python
N/A
# code by PROGIEZ
Additional Resources
- Explore all LeetCode problem solutions at Progiez here
- Explore all problems on LeetCode website here
Happy Coding! Keep following PROGIEZ for more updates and solutions.