过滤器最大值 rn
Posted
技术标签:
【中文标题】过滤器最大值 rn【英文标题】:Filter max of rn 【发布时间】:2011-03-15 09:08:13 【问题描述】:如何在此处过滤 rn 的最大值
select *
from (
select *
, row_number() over (partition by name order by ox asc) as rn
from YourTable
) as SubQueryAlias
where rn = 1
在其归档上方rn = 1
我要过滤rn = max(rn)
【问题讨论】:
【参考方案1】:将order by ox asc
更改为order by ox desc
并使用rn = 1
select *
from (
select *
, row_number() over (partition by name order by ox desc) as rn
from YourTable
) as SubQueryAlias
where rn = 1
【讨论】:
【参考方案2】:检查这个以获得 rn = max(rn):
select top 1 * from
( select * ,
row_number() over (partition by name order by ox asc)
as rn from YourTable )
as SubQueryAlias
order by rn desc
【讨论】:
以上是关于过滤器最大值 rn的主要内容,如果未能解决你的问题,请参考以下文章