当前位置: 代码迷 >> Sql Server >> 按照时间自动编号解决方案
  详细解决方案

按照时间自动编号解决方案

热度:35   发布时间:2016-04-27 20:31:07.0
按照时间自动编号
select   *   from   tb   where   ...
结果如下:
time   num
9:01   23
9:02   1.2
9:03   112
9:04   3
...     ..

希望得到如下结果:
id   time   num
1     9:01   23
2     9:02   1.2
3     9:03   112
4     9:04   3
5     ...     ..
不用临时表.


------解决方案--------------------
select *,(select count(*) from tb where a.time> =time ) from tb a where
------解决方案--------------------

select (select count(1) from tb b where a.time> =b.time) as ID, * from tb a
  相关解决方案