Earliest Date

  • I'm trying to pull the first occurance (date) of when a product hits a certain location.   The table I'm using contains ProductID (varchar 50) and InvoiceDate (DateTime).  I've tried using a "Top" clause, but of course that doesn't work.  How can I pull the first date by product?  Thanks in advance.

  • Select Min(InvoiceDate)

    From your_table

    Where product_id = '123'

    -------------------------------------

    Select top 1 InvoiceDate

    From your_table

    Where product_id = '123'

    Order by InvoiceDate

     

  • Could you provide some sample data with expected resultset ?!







    **ASCII stupid question, get a stupid ANSI !!!**

  • If you are still having a problem please post the exact statement you are trying to run, a sample of the output and why you think it is not correct.

     

  • I'm running the statement now using the "min" function.  Will keep you posted

  • Yep, that will do the trick...

  • Min worked great!  Thanks for the help.

     

     

Viewing 7 posts - 1 through 6 (of 6 total)

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