List the Products Ordered in a Period Solved(MySQL)
IntuitionIn this problem , we need to find the products that were ordered in February and determine the total number of units ordered for each product and  we o
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
In this problem , we need to find the products that were ordered in February and determine the total number of units ordered for each product and  we only want to include those  products that have a total unit count of at least 100.

# Approach
1) Firstly , we Look at the Products table and select the product_name column, which contains the names of the products.
2) Then Look at the Orders table and find the sum of units for each product using the product_id column that matches the products.
3) Filter the orders to include only those made in the specified period. We check the year and month of the order_date column.
4) Group the results by the product_id so that we can aggregate the units ordered for each product.
5) Finally, apply the condition to include only those products that have a sum of units greater than or equal to 100.

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
Time complexity:
The time complexity of the solution depends on the size of the Orders table and how efficiently the database can process the query. However, in general, your solution has a time complexity of O(n), where n is the number of rows in the Orders table that satisfy the specified conditions.

Space complexity:
The space complexity of your solution is determined by the number of distinct product_ids in the specified period. This is because we need to store and process the aggregated results for each distinct product_id. So the space complexity is O(m), where m is the number of distinct product_ids.

# Code
```mysql []
# Write your MySQL query statement below
SELECT p.product_name product_name, sum(o.unit) unit FROM Products p
JOIN Orders o USING (product_id)
WHERE YEAR(o.order_date)='2020' AND MONTH(o.order_date)='02'
GROUP BY p.product_id
HAVING SUM(o.unit)>=100
```
['MySQL']