Activity Forums Salesforce® Discussions Can I use ORDER BY and GROUP BY clause in the same query?

  • Ajit

    Member
    April 29, 2016 at 6:47 am

    SELECT Name,MAX(Test__c) FROM Account GROUP BY name ORDER BY name LIMIT 2

    Field that are aggregated cannot be used in GROUP BY or ORDER BY.

    In the above example, Test__c cannot be used in GROUP BY or ORDER BY because Test__c is aggregated.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos