34,594
社区成员
发帖
与我相关
我的任务
分享
你的cardcode , date , time存在相同的?怎么搞?用另外两个字段?
大致写法为:
select * from tb t where collectlogid = (select max(collectlogid) from tb where cardcode = t.cardcode and date = t.date and time = time)
select * from tb t where not exists (select 1 from tb where cardcode = t.cardcode and date = t.date and time = time and collectlogid > t.collectlogid)
delete tb from tb t where date not exists (select 1 from tb where id = t.id and time=T.time and date > t.date )
SELECT * FROM TB T WHERE COLLECTLOGLD=
(SELECT MAX(COLLECTLOGLD) FROM TB WHERE
DATE=T.DATE AND TIME=T.TIME AND CARDCODE=T.CARDCODE)