Hi r937,
Thanks a lot. But I found that some records may have the same datetime but are different. Another way is the group the same datetime and also the localParty and the remoteParty. These fields should have the same localParty and remoteParty for the same datetime.
The new table:
id, datetime, localParty, remoteParty, name
1, 2012-10-28 17:17:00, 1001, 9888, test
2, 2012-10-28 17:17:00, 1001, 9888, testing a long one
3, 2012-10-28 17:17:00, 1002, 9876, new one
4, 2012-10-28 17:18:01, 1234, 9000, next
5, 2012-10-28 17:18:01, 1234, 9000, next long one
6, 2012-10-28 17:19:00, 1001, 9888, same local and remote but diff datetime
It should return:
2, 2012-10-28 17:17:00, 1001, 9888, testing a long one
3, 2012-10-28 17:17:00, 1002, 9876, new one
5, 2012-10-28 17:18:01, 1234, 9000, next long one
6, 2012-10-28 17:19:00, 1001, 9888, same local and remote but diff datetime
Please help. Thanks in advance.