Activity Forums Salesforce® Discussions Can you use Group by clause inside inner query in Salesforce SOQL?

  • shariq

    Member
    September 22, 2018 at 9:45 pm

    No. only root queries support aggregate expressions. Return type is List<AggregateResult> for above query However the root result expects List<Account> and there is no syntax or provision available in Salesforce to specify that child results are of type “AggregateResult“.

  • Parul

    Member
    September 23, 2018 at 5:08 am

    SELECT Id, Name,(SELECT Count(Id),Name FROM Contacts Group By Name Having count(Id) > 1 ) FROM Account

    No only root queries support aggregate expression.

  • Avnish Yadav

    Member
    September 30, 2018 at 3:58 am

    No we cannot use  aggregate expression.
    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos