Getting the LATEST DATE in the table

  • How to modify the below procedure in order to get the latest date ( the biggest value ) in the column “Deadline”, type smalldatetime, ( example: 24/02/2007 00:00:00 ) for a given customer “UserName” ?

     

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    CREATE PROCEDURE GetLatestDate

    (@UserName VARCHAR(50)

    AS

    SELECT Deadline

    FROM CustomerItems

    WHERE UserName = @UserName

  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    CREATE PROCEDURE GetLatestDate

    (@UserName VARCHAR(50)

    AS

    SELECT Max(Deadline)

    FROM CustomerItems

    WHERE UserName = @UserName


    And then again, I might be wrong ...
    David Webb

  • Thank you, David.

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

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