SQL Server 2000 实现Row Number

Standard

思路很简单,使用一列没有重复值的列作为参考。排序后计算在此行前的行数加一就是该行号:

比如:

select (select count(1)+1 as rownum from employees t2 where t2.fullname<t1.fullname) rownum ,* from employees t1 order by t1.fullname

Leave a Reply

Your email address will not be published. Required fields are marked *