Hi I'm trying to get a unique list of ID values based on the latest (max) version number
My table looks like:
id  Version    Cost      Name     Status
---|-----|------------|--------|---------
35 | 1.0 | 200000     | john   | Open
36 | 1.0 | 400000     | juliet | Open
35 | 2.0 | 350000     | borat  | Closed
36 | 1.5 | 30000      | john   | Waiting Update
I want it to be able to return
id  Version    Cost      Name     Status
---|-----|------------|--------|---------
35 | 2.0 | 350000     | borat  | Closed
36 | 1.5 | 30000      | john   | Waiting Update
I've tried using this but can't get it to work and I'm not sure where I'm going wrong
select FB.* from CSLL.Feedback FB
inner join (
    select ID
    ,max(Version)
    ,Status as MaxID
    from CSLL.Feedback
    group by ID
) groupedID
ON FB.ID = groupedID.ID
AND FB.Version = groupedID.MaxID
and FB.Status = groupedID.Status
Which was based on a response to another question found here
Can anyone help at all?
Many thanks in advance
Tom
 
     
    