select fid=identity(int,1,1) ,fdate,fdata from table1

解决方案 »

  1.   

    alter table tablename add id int identity(1,1)
      

  2.   

    select identity(int,1,1) as fid,fdate,fdata into # from table1select * from #drop table #
      

  3.   

    临时表:你是不是想更改那表结构阿?
    select fid=identity(int,1,1),fdate,fdata into #t from table1直接查询 select * from #t
      

  4.   

    如果每天只有不超过一条记录,可以用子查询方式实现,同样适用于Access:select 
        (select count(*) from table1 where fdate<=t.fdate) as fid,
        t.fdate,
        t.fdata 
    from 
        table1 t
      

  5.   

    不好意思,写错了。create table table1 (fdate datetime,fdata varchar(4))insert into table1 
    select '2006/2/2','1234'
    union all
    select '2006/5/3','1111'
    union all 
    select '2006/7/5','2222'
    union all 
    select '2006/8/6','3333'
    union all
    select '2006/8/8','4444'
    union all 
    select '2006/9/9','5555'
    select fid=identity(int,1,1),fdate,fdata 
    into #t
    from table1select * from #t
      

  6.   

    每天只有一条纪录
    thanks very much
    trying.....
      

  7.   

    create table table1 (fdate datetime,fdata varchar(4))insert into table1 
    select '2006/2/2','1234'
    union all
    select '2006/5/3','1111'
    union all 
    select '2006/7/5','2222'
    union all 
    select '2006/8/6','3333'
    union all
    select '2006/8/8','4444'
    union all 
    select '2006/9/9','5555'
    select fid=identity(int,1,1),fdate,fdata 
    into #t
    from table1select * from #tinsert into #t 
    select '2006/8/9','6666'select *from #t order by fid呵呵,只会只一种方法,其它的就不知道了,期待。。
      

  8.   

    select fDate,fData,count(*) as fld from (
    SELECT a.* from a3 a left join a3 b on a.fdate>=b.fdate)
    group by fDate,fData