题解 | 分析每个商品在不同时间段的销售情况
分析每个商品在不同时间段的销售情况
https://www.nowcoder.com/practice/eec7a93e1ab24233bd244e04e910d2f9
select product_id,product_name, sum(coalesce(total_amount,0)) q2_2024_sales_total, rank() OVER(PARTITION BY category order by COALESCE(sum(total_amount),0) desc) category_rank, supplier_name FROM product_info s1 left JOIN (select * FROM order_info where date_format(order_date,'%y%m') between 2404 and 2406) s2 using(product_id) left JOIN supplier_info s3 using(product_id) group by 1,2,category,5 order by 1