题解 | 分析每个商品在不同时间段的销售情况
分析每个商品在不同时间段的销售情况
https://www.nowcoder.com/practice/eec7a93e1ab24233bd244e04e910d2f9
select distinct product_id,product_name ,q2_2024_sales_total , dense_rank() over ( partition by category order by q2_2024_sales_total desc ) as category_rank,supplier_name
from (
select distinct order_info.product_id,product_name, if(order_date>'2024-06-30'or order_date<'2024-04-01',0,sum(total_amount) over (partition by product_id) )as q2_2024_sales_total,
supplier_name,order_date,category
from product_info join order_info
on product_info.product_id=order_info.product_id
join supplier_info on product_info.product_id=supplier_info.product_id
) as t
order by product_id
