• This could be more efficient (esp if "pkstuff" tight and/or the table is indexed properly for the correlated SELECT):

    select CONVERT (varchar(9),EMPLOYEE_ID) AS emp_id

    , CONVERT(datetime,(CONVERT(varchar(8),ADMISSION_DTE))) AS Adm_date

    , ADMISSION_CDE

    , ADMIT_TYPE_CDE

    , CONVERT(datetime,(CONVERT(varchar(8),DISC_DTE))) AS Dis_date

    , DISC_CDE

    , DISC_TYPE_CDE

    from CurrentTable ct1

    WHERE [BranchID]='950' AND (DISC_DTE IS NULL OR (DISC_DTE > 20120630 AND DISC_DTE < 20130201))

    and ct1.admission_dte = (SELECT MAX(ct2.admission_dte) from curenttable ct1 WHERE ct1.pkstuff = ct2.pkstuff)

    order by emp_id , adm_date

    You can also solve this with this construct: , ROW_NUMBER() OVER(partition by ... order by admission_dte desc) as rownumber

    WHERE rownumber = 1

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service