Try something like this. This would give you one row per combination of field1 and field2, but whether the value of field24 that you get is the right one or not - I don't knowSELECT A.field1,A.field2,MAX(C.field24) AS field24FROM Table Ainner join Table Con A.field1 = C.field3and C.field.StartDate Between A.EffDate and ISnull(A.TermDate , CAST('12/31/2078 23:59:59' as Datetime))Where C.field24 not in ('531', ...)GROUP BY A.field1 ,A.field2