题解 | 商品价格排名

select
    product_id,
    product_name,
    type,
    price
from
    (
        select
            *,
            rank() over (
                partition by
                    type
                order by
                    price desc
            ) as rk
        from
            product_info
    ) as a
where
    a.rk in (1, 2)
order by
    price desc,
    product_name asc
limit
    3

全部评论

相关推荐

劝退式:感觉有人回才是不正常的
点赞 评论 收藏
分享
FieldMatching:看成了猪头顾问,不好意思
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务