Consider the following table:
tbl_start_times
id mach_id start_time
-- ------- ----------
1 1 00:12
2 3 05:18
3 1 03:56
4 2 01:51
5 1 12:48
6 2 00:10
7 3 09:15
I want to return id, mach_id, and MIN(start_time) for each mach_id.
The code:
SELECT mach_id, MIN(start_time) FROM tbl_start_times GROUP BY mach_id
Returns this result:
mach_id start_time
------- ----------
1 00:12
3 05:18
2 00:10
How can I add the id to my result so that I get this?
id mach_id start_time
-- ------- ----------
1 1 00:12
2 3 05:18
6 2 00:10