Easy MySQL Solution (Step by Step Guide)
IntuitionThe problem requires us to find products that had a total sales volume (units sold) of at least 100 in February 2020. Given two tables, Products and Or
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The problem requires us to find products that had a total sales volume (units sold) of at least 100 in February 2020. Given two tables, Products and Orders, the key idea is to aggregate order data by product and filter those that meet the threshold.

# Approach
<!-- Describe your approach to solving the problem. -->
**1. Join the Tables:** Since product names exist in the Products table and order details in the Orders table, we perform an INNER JOIN on product_id to combine the relevant information.
**2. Filter the Date Range:** We extract only those orders that were placed between February 1, 2020, and February 29, 2020 using the WHERE clause.
**3. Aggregate Sales Data:** We use SUM(o.unit) to calculate the total number of units sold for each product.
**4. Apply the Threshold Condition:** Using the HAVING clause, we ensure only products with total sales of at least 100 units are included in the final output.
**5. Select Required Fields:** Finally, we retrieve the product_name and the total unit count.

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

select p.product_name as product_name,sum(o.unit) as unit 
from Products p 
join Orders o on p.product_id = o.product_id 
where order_date >= '2020-02-01' and order_date <='2020-02-29' 
group by p.product_id having sum(o.unit) >= 100;

```
['Database', 'MySQL']