This is easily achieved with CTE that numbers the rows and then you can filter on rowno = 1:
; WITH numbering AS (
SELECT RecID, DateEntered, Status,
row_number() OVER(PARTITION BY RecID ORDER BY DateEntered DESC) AS rowno
FROM #Temp1
)
SELECT RecID, DateEntered, Status
FROM numbering
WHERE rowno = 1
AND Status <> 'C'
[font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]