• You can use ROW_NUMBER() to achieve the desired results

    SELECT*

    FROM(

    SELECTROW_NUMBER() OVER ( PARTITION BY Client.ID, Patient.SSN ORDER BY StartOfCare ) AS RN,

    Client.ID, Client.ClientName, Patient.ClientID, Patient.SSN, Patient.StartOfCare, Patient.PrimDiag

    FROMClient Client

    INNER JOIN Patient Patient ON Client.ID = Patient.ClientID

    WHEREPatient.RptYear = 2012 AND Patient.PrimDiag <> 'NULL' AND Patient.PrimDiag <> '' AND Patient.SSN <> ''

    ) P

    WHEREP.RN > 1


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/