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

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

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

全部评论

相关推荐

不愿透露姓名的神秘牛友
10-29 21:14
疯犬丨哈士奇:喜欢你的人会主动表白,对你有想法的人会很主动,所以要你的公司不会吊着你所以懂了吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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