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

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

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

select product_category,age_group,total_sales_amount,round(total_sales_amount/sum(total_sales_amount) over(partition by product_category),2) as purchase_percentage from(
SELECT
	category AS product_category,
	age_group,
	sum(quantity * price) AS total_sales_amount
FROM
	products p
	LEFT JOIN sales s ON p.product_id = s.product_id
	LEFT JOIN customer_info c ON s.sale_id = c.sale_id 
GROUP BY
	1,
	2 
ORDER BY
	1) t group by 1,2

全部评论

相关推荐

2025-12-11 14:24
门头沟学院 Java
牛客35720396...:不要用boss,全是骗
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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