Given the following table/query structure (simplified structure and contrived data), is there a way to find the occurrence of each MachineID’s StartTime and Status when the AbsoluteOffsetMinutes is minimized? In the example data, the AbsoluteOffsetMinutes is a calculated query field that shows the difference between the StartTime and Jan 27 9:00 AM. The Status is the state of the machine when the reading was taken.
ID MachineID StartTime AbsoluteOffsetMinutes Status
1 1 27/01/2007 8:00:00 AM 60 1
2 1 27/01/2007 8:10:00 AM 50 2
3 1 27/01/2007 8:30:00 AM 30 3
4 1 27/01/2007 8:55:00 AM 5 4
5 1 27/01/2007 9:07:00 AM 7 1
6 1 27/01/2007 9:30:00 AM 30 2
7 2 27/01/2007 8:35:00 AM 35 10
8 2 27/01/2007 8:50:00 AM 10 20
9 2 27/01/2007 9:15:00 AM 15 30
10 2 27/01/2007 9:30:00 AM 30 40
With the example data, I want the resulting query to display all the fields from record ID’s 4 and 8 (status = 4 and 20 respectively) (there are several other fields in the real table structure that also need to be displayed). I’ve been able to get the correct result by using two queries, but I am looking for a single-query solution. I recently read about using the TOP 1 clause in a query, but haven’t been able to make that work…