Using 'Group by' and 'Having' in subquery

Posts   
 
    
knez
User
Posts: 37
Joined: 01-Nov-2004
# Posted on: 26-Apr-2005 16:47:09   

Hi!

I wonder if it is possible to fetch collection of entity objects by using SQL like the following:

SELECT [LeasingAgreement].*
FROM ( [LeasingAgreement] 
INNER JOIN [LeasingAgreementObject] 
    ON  [LeasingAgreement].[LeasingAgreementId]=[LeasingAgreementObject].[LeasingAgreementId]) 
WHERE ( [LeasingAgreementObject].[AgreementObjectId] IN 
    (SELECT [AgreementObjectAttributeValue].[AgreementObjectId] AS [AgreementObjectId] 
     FROM [AgreementObjectAttributeValue] 
     WHERE ( ( [AgreementObjectAttributeValue].[AgreementObjectTypeAttributeId] = 66 
     And [AgreementObjectAttributeValue].[AgreementObjectTypeAttributeValue] = 'REG 0001') 
     Or ( [AgreementObjectAttributeValue].[AgreementObjectTypeAttributeId] = 70 
     And [AgreementObjectAttributeValue].[AgreementObjectTypeAttributeValue] = 'CHA 0001'))
     GROUP BY [AgreementObjectAttributeValue].[AgreementObjectId]
     HAVING COUNT([AgreementObjectAttributeValue].[AgreementObjectId]) = 2))

I was unable to set IGroupByCollection (and 'Having' clause) in predicate for FieldCompareSetPredicate constructor.

How can I perform task like this?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 26-Apr-2005 17:47:15   

In 1.0.2004.2, this is added. 1.0.2004.2 is now available.

Frans Bouma | Lead developer LLBLGen Pro