Need help with query to select the latest revisions of records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dhsieh
    New Member
    • Aug 2007
    • 13

    Need help with query to select the latest revisions of records

    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?
  • dhsieh
    New Member
    • Aug 2007
    • 13

    #2
    Hello again,

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

    Comment

    Working...