题解 | 对商品的销售情况进行深度分析

对商品的销售情况进行深度分析

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

select
    p.category as product_category,
    c.age_group,
    round(sum(s.quantity * s.price),2) as total_sales_amount,
    round(sum(s.quantity * s.price)/sum(sum(s.quantity * s.price)) over(partition by p.category),2) as purchase_percentage
from products p
join sales s on p.product_id=s.product_id
join customer_info c on s.sale_id=c.sale_id
group by p.category,c.age_group
order by product_category,purchase_percentage desc;

题目出得怪怪的,这题不怪自己,嘿嘿嘿👱‍♀️

全部评论

相关推荐

要AC不要WA:投一天,喜提两笔试
点赞 评论 收藏
分享
03-04 22:09
已编辑
南昌大学 golang
西北上单:29届? 请你去三角洲猛攻
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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