日期:2014-05-18 浏览次数:20517 次
delete a from 表 a where exists( select 1 from 表 where id=a.id and time <>(select min(time) from 表 where id=a.id ) and time <>(select max(time) from 表 where id=a.id ) )
------解决方案--------------------
--显示为两条记录
select * from timerecords a where sign_time=(select max(sign_time) from timerecords where card_id=a.card_id and datediff(d,sign_time,a.sign_time )=0) or sign_time=(select min(sign_time) from timerecords where card_id=a.card_id and datediff(d,sign_time,a.sign_time )=0)