题解 | 商品价格排名

select
    product_id,
    product_name,
    type,
    price
from
    (
        select
            product_id,
            product_name,
            type,
            price,
            rank() over (
                partition by
                    type
                order by
                    price desc
            ) 排名
        from
            test.product_info
    ) a
where
    排名 <= 2
order by
    price desc,
    product_id asc
limit
    3

全部评论

相关推荐

01-28 22:32
门头沟学院 C++
点赞 评论 收藏
分享
01-27 11:56
中山大学 C++
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务