|
--If there are no duplicate records, you can do this
create table T (col datetime)
insert T select '2016-12-11'
insert T select '2016-12-13'
insert T select '2016-12-12'
select ID = (select count (*) from T where col <= A.col), A. * from T as A
order by col
--result
ID col
----------- --------------------------------------- ---------------
1 2016-12-11 00: 00: 00.000
2 2016-12-12 00: 00: 00.000
3 2016-12-13 00: 00: 00.000
(3 row (s) affected) |
|