题解 | 商品价格排名

商品价格排名

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

#1.先求出每个商品类型的价格的前2名的商品。
#2.在将上述的商品在进行个排序,取前三。
with tiaojian as (
select
product_id,
product_name,
type,
price,
dense_rank()over(partition by type order by price desc) as pf
from product_info
)

select 
t.product_id,
t.product_name,
t.type,
t.price
from(
select 
product_id,
product_name,
type,
price,
row_number()over(order by price desc,product_name asc) as pdiff
from tiaojian
where
pf<=2
) as t 
where
t.pdiff<=3

全部评论

相关推荐

那一天的Java_J...:他本来公司就是做这个的,不就是正常的游戏客户端和服务器开发,软硬件联动,有啥恶心不恶心的,提前告诉你就是怕你接受不了,接受不了就没必要再往后走流程浪费时间,虽然这公司是一坨。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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