Selected records

  • Do you know what code you would use for the following :

    12345678 01/20/2003

    12345678 08/10/2002

    12345678 04/02/2002

    45678901 01/30/2003

    45678901 02/15/2002

    I want to get just the first account with the most current date and exclude the other records

    12345678 01/20/2003

    45678901 01/30/2003

  • think it goes something like this:

    Select a.col1, a.col2 from table1 a where

    a.col2 = (select top 1 col2 from table1 where a.col1 = col1 order by col2 desc)

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

  • SELECT ACC,MAX(ACCDATE) FROM tablename GROUP BY ACC

  • Thanks for the information

    Rocko..

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

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