MAX(CreatedDate)

  • Hi experts,

    Several rows may match my WHERE clause but I only want the one with the maximum created date, MAX(CreatedDate). How would I change this;

    SELECT RememberValue

    FROM dbo.Remember

    WHERE DBName = @DBName

    AND SProcSource = @SProcSource

    AND SProcVersion = @SProcVersion

    AND RememberKey=@RememberKey

    Thank you.

  • SELECT TOP (1) RememberValue

    FROM dbo.Remember

    WHERE DBName = @DBName

    AND SProcSource = @SProcSource

    AND SProcVersion = @SProcVersion

    AND RememberKey=@RememberKey

    ORDER BY CreatedDate DESC

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • Thank you Andras. This is perfect.

    Warm regards,

    Hope

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

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