题解 | 电商平台想要了解不同商品在不同月份的销售趋势

电商平台想要了解不同商品在不同月份的销售趋势

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

select
    pu.product_id,
    product_name,
    sum(quantity) as total_sales,
    max(quantity) as max_monthly_sales,
    min(quantity) as min_monthly_sales,
    round(avg(quantity),0) as avg_monthly_sales
from
    products_underline pu
join
    sales_underline su
on
    pu.product_id = su.product_id
where
    sale_month < '2024-07' and sale_month >= '2024-01'
group by
    pu.product_id,
    product_name
order by
    pu.product_id;

全部评论

相关推荐

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

创作者周榜

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