# List the Products Ordered in a Period LeetCode Solution

This Leetcode problem List the Products Ordered in a Period LeetCode Solution is done in SQL.

# List of all LeetCode Solution

## Problem Statement

product_id is the primary key (column with unique values) for this table. This table contains data about the company’s products.

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 1:
Input:

Output:

Explanation:
Products with product_id = 1 is ordered in February a total of (60 + 70) = 130.
Products with product_id = 2 is ordered in February a total of 80.
Products with product_id = 3 is ordered in February a total of (2 + 3) = 5.
Products with product_id = 4 was not ordered in February 2020.
Products with product_id = 5 is ordered in February a total of (50 + 50) = 100.

## List the Products Ordered in a Period LeetCode Solution MySQL

``````select
product_name,
sum(unit) as unit
from
Orders as o
left join Products as p on o.product_id = p.product_id
where
order_date between '2020-02-01'
and '2020-02-29'
group by
o.product_id
having
sum(unit) >= 100;```Code language: SQL (Structured Query Language) (sql)```
Scroll to Top