You need to sign in to do that
Don't have an account?

SOQL query need help urgent...thanks
this query returns the sum of all the tasks on Sales_Resources__c object...but i want to get the sum of closed tasks of particular record...
if object has 5 records and record 1 contain 2 closed tasks..then i want to get the sum of only those two tasks...
\but this query returning the sum of all the tasks of this object's records...
can sm1 help...
aggregateResult[] results = [Select SUM(Minutes_on_tasks__c)summ From Task WHERE status = 'Completed' AND Minutes_on_tasks__c != null AND whatid IN (SELECT Id FROM Sales_Resources__c)];
Hi,
Use the Group By clause in your query.
This should give you the sum of the Minutes on Task field for particular records.
All Answers
If there are Tasks associated with a record related to the Sales_Resources__c record, your SOQL should query Task for that WhatID. Currently, the SOQL is querying for all Sales_Resource Tasks, and not tasks assosiated with that other record.
thanks for ur reply
can u change this query...? i m not able to do that
Try below :-
aggregateResult[] results = [Select SUM(Minutes_on_tasks__c)summ From Task WHERE status = 'Completed' AND Minutes_on_tasks__c != null AND whatid IN (SELECT Id FROM Sales_Resources__c where name='<some Sales_Resources__c record name>')];
but we have 100's of records in this object..how can i give all these names...but yes they are linked to record type...
Hi,
Use the Group By clause in your query.
This should give you the sum of the Minutes on Task field for particular records.
not working...i tried Group by whatid..it is working on some records and giving abnormal results on other records...
m not able to understand where the problem is...
How are you referencing the results of the query?