先導入臨時表:
select identity(int,1,1) id0,* into #temp1 from yourtable order by date;再從臨時表選取數據:
select * from #temp1;

解决方案 »

  1.   

    可以利用server2000中的用户自定义函数,
    但必须保证有个字段唯一,这里假设date(datetime)字段唯一
    create function fn_num(@p_date datetime)
    returns int
    as
    begin
    return(select count(*) from mytable where date<=@p_date)
    end
    --在语句中这样调用
    select fn_num(date),col1,col2.... from mytable
      

  2.   

    例:
    select rownum,coulmn1,...,coulmnN 
    from table_name 
    where ... ; //条件//如果不按数据库顺序排,要按自己的顺序的话可能就要费点劲,如下的写法
    select rownum,coulmn1,...,coulmnN 
    from (
    select * from table_name
    where ...     //过虑条件
    order by ...  //排序方式
    );
      

  3.   

    to zhuzhichao(竹之草) :
    我照你的方法试了一下,但是奇怪的是序号并不是按照 order by date这个条件排序的,而是按照原来的顺序,为什么呢??有什么办法可以解决吗
      

  4.   

    看來你對臨時表有疑惑.
    請去看帖子:
    http://www.csdn.net/expert/topic/286/286094.shtm我說的很詳細.