This might sound silly and not 'best practiced' but if the original query performs good enough could you just wrap it as sub-query and then filter the result?
Select * From
(previous query) a
Where filterfield = 1
Silly me....
>>>If you want the fastest result, then try packed value solution from that blog.
>>
>>Thanks
>
>Here it is - no need for derived tables
>
>
>declare @t table(PK int, ChildPK int, Field int)
>insert into @t values(1,1,1), (1,2,3), (1,3,0), (2,4,5), (2,1,1), (2,2,3)
>
>select PK, MAX(Field) as MaxField,
>cast(SUBSTRING(max(cast(Field as binary(10)) + CAST(ChildPK as binary(10))),11,10) as int) as ChildPk
>from @t group by PK
>
Ricardo A. Parodi
eSolar, Inc.