Connecting Tech Pros Worldwide Forums | Help | Site Map

Need help with query to select the latest revisions of records

Newbie
 
Join Date: Aug 2007
Posts: 13
#1: Sep 6 '07
Hello all,

I have a revisions table with the fields uniqueID, originalID, revNumber, data1, data2 and so on. What I am trying to do is select only the latest revisions for every unique originalID.

For example, if I have the records of uniqueID, originalID, revNumber as follows:
1, 1, 1
2, 1, 2
3, 1, 3
4, 1, 4
5, 2, 1
6, 2, 2
7, 3, 1
8, 3, 2

I want to be able to get uniqueIDs 4, 6, and 8 in the result set.

I've experiemented with a mixture of ORDER BY and GROUP BY clauses with no luck. Can anyone please help?

Newbie
 
Join Date: Aug 2007
Posts: 13
#2: Sep 6 '07

re: Need help with query to select the latest revisions of records


Hello again,

I've solved my previous problem with using GROUP BY originalid and ORDER BY originalid DESC.
Reply