I have this table of attendance system with columns dateinout, checkin, checkout etc. user punch in when come to office and punch out when go out. system retrieve data two time from fingerprint scanner machine. I want to delete rows with more than one count in same date where punch in is between 7am to 11 am also the rows with check out with same date in between 11 am to 6 pm.
SELECT
a.Logid,
a.Userid,
a.CheckTime,
a.Name
FROM Checkinout a
JOIN
(SELECT
userid,
name,
dateinout,
Intime,
Outtime
FROM att
WHERE Intime BETWEEN '07:00:00.0000000' AND '11:00:00.0000000'
AND userid= 37
GROUP BY userid, dateinout, Intime, Outtime, name
HAVING COUNT(Intime)>1) b
ON a.Userid= b.userid
ORDER BY CheckTime ASC;