+1 vote
48 views
by (163k points)

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'
                )
        ];
    }
}

1 Answer

+1 vote
by (163k points)
 
Best answer

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

Welcome to Memory Exceeded, where you can ask questions and receive answers from other members of the community.
...