Home Forums SQL Server 2008 T-SQL (SS2K8) How to get minimum date of an ID with respect to startdate? RE: How to get minimum date of an ID with respect to startdate?

  • Charmer (2/8/2016)


    OMG,

    I am sorry, Chris. The script is still wrong.

    Just see the screen shot attached in here. The ID 4, having startdate '2016-01-27' should show '2016-01-26'

    instead of '2016-01-27'. because we have '2016-01-26' is the minimum date to '2016-01-27'

    Easy enough - correct your scripts. Also, rather than using GETDATE() and arithmetic, use hardcoded date values.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden