How to show the MIN Date Value in a query

  • After reading many posts, this is what I learned.

    SELECT MIN(StartDate) AS MinDate FROM Schedule WHERE WorkCenterID = 'LAY-W' AND ScheduleID = '5' GROUP BY StartDate

    It produces all three values.  I just want the Minimum Date Value to be returned.

     

    Thanks!

     

    Steve Anderson

  • If you want a single, minimum value returned, don't group the data.

    The above is all just my opinion on what you should do. 
    As with all advice you find on a random internet forum - you shouldn't blindly follow it.  Always test on a test server to see if there is negative side effects before making changes to live!
    I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.

  • Exactly.  Just this:

    SELECT MIN(StartDate) AS MinDate

    FROM Schedule

    WHERE WorkCenterID = 'LAY-W' AND ScheduleID = '5'

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

  • This was removed by the editor as SPAM

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

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