select identity(int,1,1) as fid,fdate,fdata into # from table1select * from #drop table #
临时表:你是不是想更改那表结构阿? select fid=identity(int,1,1),fdate,fdata into #t from table1直接查询 select * from #t
如果每天只有不超过一条记录,可以用子查询方式实现,同样适用于Access:select (select count(*) from table1 where fdate<=t.fdate) as fid, t.fdate, t.fdata from table1 t
不好意思,写错了。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
每天只有一条纪录 thanks very much trying.....
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呵呵,只会只一种方法,其它的就不知道了,期待。。
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
select fid=identity(int,1,1),fdate,fdata into #t from table1直接查询 select * from #t
(select count(*) from table1 where fdate<=t.fdate) as fid,
t.fdate,
t.fdata
from
table1 t
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
thanks very much
trying.....
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呵呵,只会只一种方法,其它的就不知道了,期待。。
SELECT a.* from a3 a left join a3 b on a.fdate>=b.fdate)
group by fDate,fData