FieldCompareSetPredicate with MAX and GROUP BY

Posts   
 
    
sbense
User
Posts: 55
Joined: 24-Jul-2007
# Posted on: 15-Aug-2007 15:55:15   

I can't figure out how to build the FieldCompareSetPredicate for the SQL here


SQL:
..
AND r.RevID IN (SELECT MAX(RevID) FROM tableA GROUP BY DocID)
..

where r is an alias for tableA

This is what I have so far


VB.NET:
inClauseRevision = New FieldCompareSetPredicate(TableAFields.RevId, Nothing, TableAFields.RevId.SetAggregateFunction(AggregateFunction.Max), Nothing, SetOperator.In, subFilter, relationsIN)

and it renders the following SQL:


[DBName].[dbo].[TableA].[RevID] 
IN (SELECT MAX([DBName].[dbo].[TableA].[RevID]) AS [RevId] 
FROM [DBName].[dbo].[TableA] )

How do I add the Group By part to this FieldCompareSetPredicate ? Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 15-Aug-2007 16:40:58   

There are multiple overloads of FieldCompareSetPredicate constructor, one of them takes GroupByCollection as a parameter. Please consult the reference manual.