题解 | 分析每个商品在不同时间段的销售情况

分析每个商品在不同时间段的销售情况

https://www.nowcoder.com/practice/eec7a93e1ab24233bd244e04e910d2f9

select a.product_id,product_name,
sum(case when total_amount is not null then total_amount else 0 end) as q2_2024_sales_total,
rank() over(partition by category order by sum(total_amount) desc) as category_rank,
supplier_name
from product_info a 
left join order_info b
on a.product_id = b.product_id and order_date between '2024-04-01' and '2024-06-30'
left join supplier_info c 
on a.product_id = c.product_id
group by a.product_id 
order by a.product_id 

全部评论

相关推荐

2025-12-19 15:04
门头沟学院 Java
小肥罗:hr爱上你了,你负责吗哈哈
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务