select * from TimeRecords a where a.Sign_DateTime =(select min(b.Sign_DateTime) from TimeRecords b
where a.Card_ID=b.Card_ID and DateDiff(Mi,a.Sign_DateTime,b.Sign_DateTime)<=0 and DateDiff(Mi,a.Sign_DateTime,b.Sign_DateTime)>=-5)
------解决方案--------------------
那再写一句update语句啊 update timerecords set Records_State=2 where 主键 in( select 主键 from TimeRecords a where a.Sign_DateTime =(select min(b.Sign_DateTime) from TimeRecords b where a.Card_ID=b.Card_ID and DateDiff(Mi,a.Sign_DateTime,b.Sign_DateTime)<=0 and DateDiff(Mi,a.Sign_DateTime,b.Sign_DateTime)>=-5) )