Table Doc
-- --
1 1
1 2
1 3*
2 1
2 2*
3 1
3 2*
4 1
4 2
4 3
4 4*
5 1*
To get maximum versions for each document
SELECT D.ID, D.Version
FROM Doc D
INNER JOIN (SELECT ID, MAX(Version) FROM Doc GROUP BY ID) DM ON D.ID = DM.ID
Thanks Dinos for the inspiration!
Dinos is always happy to help!
ReplyDelete