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

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

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

select 
    product_id,
    product_name,
    sum(case when order_date between '2024-04-01' and '2024-06-30' then total_amount else 0 end) as q2_2024_sales_total,
    rank() over(partition by category order by sum(case when order_date between '2024-04-01' and '2024-06-30' then total_amount else 0 end) desc) as category_rank,
    supplier_name
from product_info 
    join order_info using(product_id) 
    join supplier_info using(product_id)
group by product_id,product_name,supplier_name
order by product_id;

全部评论

相关推荐

ros275229:社团删了吧,cf因该1200才勉强入门吧,也删了,你可以写算法刷了多少道,都比这个好
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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