Skip to main content
June 3, 2008
Answered

SQL - Finding the minimum value for each distinct record..

  • June 3, 2008
  • 2 replies
  • 481 views
Hi All,

I have a table looks like this in SQL Server

Product Sale Date
A date
A date
A date
B date
B date
C date
C date
C date

I would like to write a query to find the minimum date (i.e. the date
of the first sale) for each product

Thus, the expected output would be

Product Sale Date
A min date
B min date
C min date

How can i do this using SQL Server??

any help is greatly appreciated!

Thanks!

    This topic has been closed for replies.
    Correct answer Etienne
    SELECT product, MIN(sale_date)
    FROM your_table
    GROUP BY product


    Etienne

    2 replies

    June 3, 2008
    That solved it then.. Thanks a bunch...
    EtienneCorrect answer
    Participating Frequently
    June 3, 2008
    SELECT product, MIN(sale_date)
    FROM your_table
    GROUP BY product


    Etienne