Coding Test

Leetcode - 1084. Sales Analysis III

Indo Yoon

문제

Loading...
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.

정답

SELECT Product.product_id, product_name
FROM Product
JOIN (SELECT product_id, MIN(sale_date) as min_date, MAX(sale_date) as max_date
      FROM Sales GROUP BY product_id
     ) As NewSales
ON Product.product_id = NewSales.product_id
WHERE NewSales.min_date BETWEEN '2019-01-01' AND '2019-03-31'
AND NewSales.max_date BETWEEN '2019-01-01' AND '2019-03-31'