Finding the latest revision in SQL 2005 database

  • I have a database containing a table listing the revision history of drawings. Let's say drawing1 has 5 revisions A,B,C,D,and E. I want my query to return only the latest one, in this case "F". What function do I use to do this.

    Thanks for any help that can be offered.

  • This is a SQL Server 2000 forum, but you write you have SQL Server 2005.

    SELECT Col1, Col2, Col3

    FROM (

    SELECT Col1, Col2, Col3, ROW_NUMBER() OVER (PARTITION BY DrawingID ORDER BY Revision DESC) AS RecID

    FROM Table1

    ) AS d

    WHERE RecID = 1


    N 56°04'39.16"
    E 12°55'05.25"

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply