1 select count(*) from table1 where ...
2
create proc delrec
AS
BEGIN
select distinct * into #t1 from table1
delete a
from table1 a,#t1 b
where a.field1=b.field1 and a.field2=b.field2 and ...
and a.fielddatetime>b.fielddatetime
END
2
create proc delrec
AS
BEGIN
select distinct * into #t1 from table1
delete a
from table1 a,#t1 b
where a.field1=b.field1 and a.field2=b.field2 and ...
and a.fielddatetime>b.fielddatetime
END
2.select distinct * into #temptable from tablename
drop table tablename
go
select * into tablename from #tamptable
drop table #temptable
go
create proc delrec
AS
BEGIN
select * into #t1 from table1 group by field1,...fieldn
trancate table table1
insert into table1 select * from #t1
END
后统计的数字是 2000,而把and tim like '[2002-6-1]%'去掉后检索全表数字还是 2000,不知为什么?
and tim < '2002-7-1'
查询所有2002年6月select count(*) from tablename where id=101110 and tim >= '2002-6-1'
and tim < '2002-6-2'
查询所有2002年6月1日select count(*) from tablename where id=101110 and tim >= '2002-6-10'
and tim < '2002-6-20'
查询所有2002年6月中旬
不知道你的原意是哪一个!