题解 | 对商品的销售情况进行深度分析
对商品的销售情况进行深度分析
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;
题目出得怪怪的,这题不怪自己,嘿嘿嘿👱♀️
