select * into tb_test1 from tb_toupiao
drop table tb_test1
drop table tb_test2
delete m from tb_test1 m where id not in (select min(id) from tb_test1 n where m.addtime = n.addtime and m.usid = n.usid )
select min(addtime) from tb_test1 where ptid=34566 group by convert(varchar(10),addtime,120),usid
select top 10 * from tb_photo order by ptrq desc
select count(*) from tb_test1
select count(*) from tb_test1 where ptid=34566
select count(*) from tb_test2 where ptid=34566
delete from tb_test1 as tb1 where id not in(select min(id) from tb_test1 where )
delete tb_test1 from tb_test1 as tb1 where id not in(select min(id) from tb_test1 as tb2 where convert(varchar(10),tb1.addtime,120)=convert(varchar(10),tb2.addtime,120) and tb1.usid=tb2.usid)
delete a from tb_test2 as a
where exists (select 1 from tb_test2 where addtime=a.addtime and usid=a.usid and id>a.id)