题解 | #每个供应商成本最低的产品#

每个供应商成本最低的产品

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

# select 

#     vend_id,

#     min(prod_price) as cheapest_item

# from Products

# group by vend_id

# order by cheapest_item

select 

    vend_id,

    prod_price as cheapest_item

from

(

    select 

        vend_id,

        prod_price,

        row_number() over(partition by vend_id order by prod_price) rn

    from Products

)t1

where rn = 1

order by cheapest_item

全部评论

相关推荐

点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务