sql server 2005 排名提供dense_rank() 函数.实现起来非常简单.
示例如下:
declare @t table(place int,score int)
insert into @t select 11,10
union all select 3,10
union all select 2,20
union all select 2,30
select dense_rank()over(order by score ) as id,score from @t

/**//*
id score
-------------------- -----------
1 10
1 10
2 20
3 30
(4 行受影响)
*/
本文介绍 SQL Server 2005 中 DENSE_RANK 函数的使用方法,通过示例展示了如何为查询结果分配连续排名,即使某些记录具有相同的评分也会得到相同排名。

84

被折叠的 条评论
为什么被折叠?



