You need to sign in to do that
Don't have an account?
Arjunmca
Hi,
I am writing a relationship query to getch multiple values in a single query.
'select contact.Account.ID,SUM(Contact.NoOfPagesPrinted__C) from contact where Contact.DatePrinted__c = LAST_N_DAYS:30 and Contact.Account.AccountType__c=:acType group by Contact.Account.ID'
The above query is working. But i want sum of pages printed for last 90 and 120 pages as well.
So i modified the query as below
'select contact.Account.ID,SUM(Select Contact.NoOfPagesPrinted__C from contact where Contact.DatePrinted__c = LAST_N_DAYS:30), sum( Select Contact.NoOfPagesPrinted__C from contact where Contact.DatePrinted__c = LAST_N_DAYS:90), sum( Select Contact.NoOfPagesPrinted__C from contact where Contact.DatePrinted__c = LAST_N_DAYS:120) from contact where Contact.Account.AccountType__c=:acType group by Contact.Account.ID'.
but its giving error. Can any body correct this query please.
Thanks.
Parent and child relationship query with aggregate values.
Hi,
I am writing a relationship query to getch multiple values in a single query.
'select contact.Account.ID,SUM(Contact.NoOfPagesPrinted__C) from contact where Contact.DatePrinted__c = LAST_N_DAYS:30 and Contact.Account.AccountType__c=:acType group by Contact.Account.ID'
The above query is working. But i want sum of pages printed for last 90 and 120 pages as well.
So i modified the query as below
'select contact.Account.ID,SUM(Select Contact.NoOfPagesPrinted__C from contact where Contact.DatePrinted__c = LAST_N_DAYS:30), sum( Select Contact.NoOfPagesPrinted__C from contact where Contact.DatePrinted__c = LAST_N_DAYS:90), sum( Select Contact.NoOfPagesPrinted__C from contact where Contact.DatePrinted__c = LAST_N_DAYS:120) from contact where Contact.Account.AccountType__c=:acType group by Contact.Account.ID'.
but its giving error. Can any body correct this query please.
Thanks.
You can refer below link it may help to understand the Aggregate funtions.
http://blog.jeffdouglas.com/2010/02/22/soql-how-i-query-with-thee-let-me-count-the-ways/
Thanks
Shailu