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

How to Learn Salesforce Development | Salesforce learning steps for beginners | Trailhead demo

Video in

In this video, we shared the steps to learn salesforce lightning basics, salesforce apex development, CRM in online for free from scratch very quickly. Learn salesforce…