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

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

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

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

全部评论
base南京,机会多多
点赞 回复 分享
发布于 2025-09-08 19:26 贵州

相关推荐

评论
点赞
收藏
分享

创作者周榜

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