Top-Selling Products in February 2020- Easy Solution
IntuitionTo find the products that were ordered in significant quantities during February 2020, we want to join the Products and Orders tables and sum up the nu
# Intuition
To find the products that were ordered in significant quantities during February 2020, we want to join the `Products` and `Orders` tables and sum up the number of units per product.

# Approach
Use an inner join between `Products` and `Orders` on `product_id`. Filter the results to only include orders from February 2020 using a `WHERE` clause. Group the results by product and sum the units ordered. Use `HAVING` to only return products with a total of 100 or more units sold.

# Complexity
- Time complexity:
$$O(n)$$ where *n* is the number of rows in the `Orders` table (due to scanning and grouping).

- Space complexity:
$$O(k)$$ where *k* is the number of unique products in the result set.

# Code
```mysql []
# Write your MySQL query statement belows

select p.product_name , sum(o.unit) as unit from Products p join Orders o
on p.product_id = o.product_id
WHERE o.order_date BETWEEN DATE '2020-02-01' AND DATE '2020-02-29'
group by o.product_id
having sum(unit)>=100
```
['MySQL']