Select MAX record.

  • I'm being a bit thick I know but could some one tell me how to select the following record.

    ID DESC REV DATE

    A X 1 01/01/2010

    A X 2 01/03/2010

    A X1 3 01/09/2010

    I want to select the record with the max date. In the case of the above I want A,X1,3,01/09/2010.

    Please note that this data is initially held in Oracle but I can extract all the records above to SQL and then run another query on the above data.

    The data is extracted from three tables, one acting in the middle as a link to the third (nightmare:-( ).

  • The very simplest way is:

    SELECT TOP 1

    ID

    , [DESC]

    , [REV DATE]

    FROM myTable

    ORDER BY

    [REV DATE] DESC

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

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