Hi,
I have a table which holds a document number, revision number and userid
SELECT DocumentID, RevNr, UserID FROM [CMD].dbo.Revisions
I am wanting to return the latest revision number for each document stored in the table. I have tried using DISTINCT and GROUP BY but as the RevNr and UserID may vary against each DocumentID I get several records for each DocumentID.
The closest I got was
SELECT DocumentID, MAX(RevNr) as 'Latest Revision' FROM dbo.Revisions GROUP BY DocumentID
But as soon as I tried adding in the UserID it didn't work. I have also tried different JOINS but I have had no success, so any help would be great.