I am trying to get a specific output out of the following data with the use of SQL, which is much faster than recordset manipulation. Cannot seem to be able to select the last record of the Group as indicated below.
Thanks in advance,
John
Output required is (indicated in red above)
AAA 1 177 7-Apr-11 17:00:00
AAA 1 188 7-Apr-11 17:00:00
In other words
SELECT WHERE strCC = 1
AND strCC <> strAC (ie Where 1 <> 1)
SORT ASC by dtmDate and dtmTime
GROUP BY strAC (in this case 123, 177, 188)
to output the last record of each GROUP if strPointer = Null
Thanks in advance,
John
Code:
DATA
[COLOR=darkorange]strDescription strCC strAC dtmDate dtmTime strPointer[/COLOR]
AAA 1 1 7-Apr-11 09:00:00
AAA 1 1 7-Apr-11 09:05:00
AAA 1 1 7-Apr-11 09:07:00
AAA 1 1 7-Apr-11 11:00:02
AAA 1 1 7-Apr-11 13:03:00
AAA 1 1 7-Apr-11 14:05:00
AAA 1 1 7-Apr-11 17:34:32
AAA 1 123 7-Apr-11 10:00:00 13
AAA 1 123 7-Apr-11 11:00:00
AAA 1 123 7-Apr-11 12:00:00 13
AAA 1 123 7-Apr-11 15:00:00 18
AAA 1 123 7-Apr-11 16:00:00
AAA 1 123 7-Apr-11 17:00:00 18
AAA 1 177 7-Apr-11 10:00:00 15
AAA 1 177 7-Apr-11 11:00:00
AAA 1 177 7-Apr-11 12:00:00 15
AAA 1 177 7-Apr-11 15:00:00 19
AAA 1 177 7-Apr-11 16:00:00
[COLOR=red]AAA 1 177 7-Apr-11 17:00:00[/COLOR]
AAA 1 188 7-Apr-11 10:00:00 21
AAA 1 188 7-Apr-11 11:00:00
AAA 1 188 7-Apr-11 12:00:00 21
AAA 1 188 7-Apr-11 15:00:00 22
AAA 1 188 7-Apr-11 16:00:00
[COLOR=red]AAA 1 188 7-Apr-11 17:00:00[/COLOR]
BBB 2 2 7-Apr-11 14:05:00
BBB 2 2 7-Apr-11 17:34:32
BBB 2 228 7-Apr-11 10:00:00 23
BBB 2 228 7-Apr-11 11:00:00
BBB 2 228 7-Apr-11 12:00:00
Output required is (indicated in red above)
AAA 1 177 7-Apr-11 17:00:00
AAA 1 188 7-Apr-11 17:00:00
In other words
SELECT WHERE strCC = 1
AND strCC <> strAC (ie Where 1 <> 1)
SORT ASC by dtmDate and dtmTime
GROUP BY strAC (in this case 123, 177, 188)
to output the last record of each GROUP if strPointer = Null