Coding Test

Leetcode - 1327. List the Products Ordered in a Period

Indo Yoon

Problem

LeetCode - The World’s Leading Online Programming Learning Platform
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

Solution

SELECT product_name, unit
FROM Products
JOIN (
    SELECT product_id, SUM(unit) as unit
    FROM Orders
    WHERE order_date BETWEEN '2020-02-01' AND '2020-02-29'
    GROUP BY product_id
) AS Orders ON Products.product_id = Orders.product_id
WHERE Orders.unit >= 100