Hi,
Grouping and aggregates will suit your needs.
Groups work by showing a unique column value but actually the rest of the columns are aggregated in that group. You can use aggregate functions on those columns to show min, the lowest of the aggregate values, max, that highest, avg, average of all aggregates, count to show the number of aggregates and so on...
Some aggregates can only be performed on numeric fields, such as avg, but most other will work on any field type.
Min will work on the string format 08:30:00 but it will work "lexicographically". This means that it will perform a character test starting with the left most character: so as long as they are varchar and not int: "9" will be higher that "10" and "99" will be higher that "10000000" but 09 will be lower that 10.
This being so, it will work on your time format because you have leading zeros:
Select
enrollNumber,
DateAttendance,
Min(TimesInOut) as FirstTimeIn,
From table
Where
Mode=0
Group By
enrollNumber,
DateAttendance
Just as an aside: After the Group By you can include the
HAVING
section. This works like the
WHERE
section but you can include aggregate fields that you cannot in the
WHERE
section.
You could have
HAVING EnrollNumber = 40
but that would not be efficient. It's best to keep that in the
WHERE
section so it's excluded before the grouping.
I use it to find duplicates so I might have
HAVING count(*) > 1
Hope that helps ^_^
Andy