题解 | 商品价格排名

商品价格排名

https://www.nowcoder.com/practice/119f5b8cfe5b45779a3e1b3f4d83b341

select
    product_id,
    product_name,
    type,
    price
from
    (
        with rank_product_info as(
            select 
                product_id,
                price,
                type,
                product_name,
                rank() over(partition by type order by price desc) as ranking
            from product_info
        )
        select *
        from rank_product_info
        where ranking < 3
    ) as top2_product_info
order by 
    price desc, product_id
limit 3

全部评论

相关推荐

10-26 13:03
已编辑
门头沟学院 物流经理
在okr拆解的小太阳...:实习待过,我待的部门氛围很好,基本不加班,双休有保证。
投递正浩创新EcoFlow等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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