April 23, 2013 at 4:29 pm
In order to solve this sort of problem using Group By queries, you need to use multiple queries. The Max function is simply taking the Max function of the record where the Min was found, and that's because the Min only has one record, the minimum (which is the CheckIn record). The problem is often solved by using ADO or DAO record processing from VBA, and simply stepping through the records. One complication that has to be dealt with in either case is where there is a checkin record but no checkout record. It shouldn't happen, but it invariably will at some point.
Wendell
Wendell
Colorful Colorado
You can't see the view if you don't climb the mountain!
May 16, 2013 at 2:38 am
You need to group by just the date portion of CHECKTIME - try this or similar
SELECT inf.SSN AS EmpNo, Format(ck.CHECKTIME, "dd/mm/yyyy") AS CHKDATE,Min(ck.CHECKTIME) AS TIMEIN, Max(ck.CHECKTIME) AS TIMEOUT
FROM CHECKINOUT ck INNER JOIN USERINFO inf ON ck.Badgenumber = inf.Badgenumber
WHERE (((ck.CHECKTIME)>=#20/03/2013#)
Group By inf.SSN, format(ck.CHECKTIME, "yyyymmdd")
ORDER BY inf.SSN, format(ck.CHECKTIME, "yyyymmdd")
Viewing 2 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply