题解 | 对商品的销售情况进行深度分析
对商品的销售情况进行深度分析
https://www.nowcoder.com/practice/d6ced1b60af64a4998169ae717672e8e
with a as(
select
category,
age_group,
sum(price*quantity) as total_sales_amount
from sales s
join products p on s.product_id = p.product_id
join customer_info c on c.sale_id = s.sale_id
group by category,age_group)
select
category as product_category,
age_group,
total_sales_amount,
round(total_sales_amount/sum(total_sales_amount)over(partition by category),2) as purchase_percentage
from a
order by product_category, purchase_percentage desc
传音控股公司福利 356人发布