leetcode 1084 销售分析III

leetcode 1084 销售分析III

select distinct p.product_id, p.product_name from Product p
left join Sales s
on p.product_id = s.product_id
where  s.product_id not in (
    select product_id from Sales
    where sale_date < '2019-01-01'
    or sale_date > '2019-03-31' 
)

 

select 
    product_id, product_name 
from 
    product p
where
    p.product_id in (
    select s.product_id from sales s group by s.product_id
    having max(s.sale_date) <= date('2019-03-31')
    and 
    min(s.sale_date) >= date('2019-01-01')
    )

==

posted @ 2023-05-11 17:59  Carl_ZhangJH  阅读(18)  评论(0)    收藏  举报