以下例子根据Item 分组后.排序. 应用例子如下: if exists(select 1 from sys.objects where object_id=object_id('tab'))begin drop table tabendgocreate table tab(item int, date datetime, temp int)insert tab select 10,'2006-01-01',0union all select 10,'2006-02-01',0union all select 10,'2006-03-01',0union all select 20,'2006-01-01',0union all select 20,'2006-02-01',0union all select 30,'2006-01-01',0union all select 30,'2006-02-01',0union all select 30,'2006-03-01',0union all select 30,'2006-04-01',0union all select 30,'2006-05-01',0goselect *,row_number() over(partition by item order by date ) as t from tabgo--结果/**//*item date temp t----------- ----------------------- ----------- --------------------10 2006-01-01 00:00:00.000 0 110 2006-02-01 00:00:00.000 0 210 2006-03-01 00:00:00.000 0 320 2006-01-01 00:00:00.000 0 120 2006-02-01 00:00:00.000 0 230 2006-01-01 00:00:00.000 0 130 2006-02-01 00:00:00.000 0 230 2006-03-01 00:00:00.000 0 330 2006-04-01 00:00:00.000 0 430 2006-05-01 00:00:00.000 0 5(10 行受影响)*/