Leetcode Note: MySQL - Sales Analysis III

Sales Analysis III - LeetCode
https://leetcode.com/problems/sales-analysis-iii/

  • MySQL で取り組んだメモ

回答

simple MySQL solution - LeetCode Discuss
https://leetcode.com/problems/sales-analysis-iii/discuss/315906/simple-MySQL-solution

SELECT s.product_id, product_name
FROM Sales s
LEFT JOIN Product p
ON s.product_id = p.product_id
GROUP BY s.product_id
HAVING MIN(sale_date) >= CAST('2019-01-01' AS DATE) AND
       MAX(sale_date) <= CAST('2019-03-31' AS DATE)