If I understod correctly this is a possible soultion for returning only one row from a account_nbr that has multiple records
-- Just inserting sample data here. WITH CTE AS ( SELECT Account_Nbr = 123, Timestmp = GETDATE() , Operator = 1, DOB = '19700101' UNION ALL SELECT Account_Nbr = 123, Timestmp = GETDATE() , Operator = 2, DOB = ' ') --No distinct necessary since it will always group by account_nbr and timestamp. SELECT Account_Nbr, Timestmp, DOB_Ordered = (CASE WHEN MAX(DOB) <> ' ' THEN 'Y' ELSE 'N' END) FROM CTE GROUP BY [Account_Nbr], [Timestmp]
CLICK HERE to find out more related problems solutions.