刷卡進出數據存儲在同一表中,姓名有重復的,一個人可能刷了2次,要求選出在時間段2014-12-28 11:00:00到2014-12-28 13:00:00內兩次刷卡記錄時間間隔大於等於40分鐘的員工
logtime (時間 )logcard (卡號 )logid () logname(姓名) logbm (部門)
```select *
from 同一表 a
where logtime between '2014-12-28 11:00:00' and '2014-12-28 13:00:00'
and exists (select 1 from 同一表 where logcard=a.logcard and logtime between '2014-12-28 11:00:00' and '2014-12-28 13:00:00' and (logtime>a.logtime + 40/60/24 or logtime<a.logtime - 40/60/24))