0

Here is my code

public with sharing class estimatevsPipeline {
    @AuraEnabled
    public static List<Opportunity> getestimatevsPipeline() {
        return [
            SELECT SUM(amount_ge_og__c) sumAmount
            FROM Opportunity
            WHERE
                ((IsClosed != TRUE
                AND ForecastCategoryName IN ('Commit', 'Commit at Risk'))
                OR StageName = 'Closed Won')
                AND RecordType.DeveloperName != 'Targets'
                AND Type IN ('Internal to GE Parent', 'Internal to BHGE', 'External')
                AND forecast_pipeline_exception_ge_og__c != TRUE
                AND CloseDate = THIS_QUARTER
                AND Id IN (
                    SELECT OpportunityId
                    FROM OpportunityTeamMember
                    WHERE
                        (UserId IN ('0051H000009S5D2QAK', '00512000007jB49AAE', '0051H00000Aw9VbQAJ')
                        OR UserId = '0051H00000AwEezQAF')
                        AND TeamMemberRole != 'Following'
                )
        ];
    }
}
2
  • hi @rahulgawale, the error is different from what you suggested. Oct 22, 2020 at 7:39
  • 1
    Nope, it's the same, the difference is that you are using a different object. Oct 22, 2020 at 7:41

1 Answer 1

0

The issue is that you're using SUM function, this can only be used with Aggregated Queries. If so you should probably GROUP BY result by some field and change return type of the method to List<AggregateResult>.

If you want just a normal query then remove SUM from SELECT.

Here is also docs on how to use Aggregation in SOQL.

Hopefully, this helps

1
  • @Gaurav Kumar Pandey if I answered your question. please consider marking it as an answer
    – ytiq
    Oct 22, 2020 at 10:15

Not the answer you're looking for? Browse other questions tagged .