题解 | 电商平台需要对商品的销售和评价情况进行综合分析

电商平台需要对商品的销售和评价情况进行综合分析

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

select
    p.product_id as product_id,
    product_name,
    sum(quantity) as total_quantity,
    round(average_rating, 2) as average_rating
from
    products_underline as p
    inner join sales_underline as s on p.product_id = s.product_id
    inner join (
        select
            product_id,
            avg(rating) as average_rating
        from
            reviews_underline
        group by
            product_id
    ) as r on p.product_id = r.product_id
where
    substr(sale_date, 1, 4) = '2024'
group by
    p.product_id
having
    average_rating < 4
order by
    average_rating asc,
    product_id asc;

全部评论

相关推荐

2025-12-13 14:51
已编辑
井冈山大学 算法工程师
龙虾x:算法比你强的没有你美,比你美的…..算了已经没有比你美的了
工作两年想退休了
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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