What is the correct SOQL statement for counting a grouped by SOQL?
I have built a SOQL and added the count field to the object. I have used an object which can hold the phrases provided in the search box, and every record refers to one search. Since I want to count my searches and represent them in descending order, my intention is to make it appear among the top 5 searches, or it should appear on a VF page. Which SOQL statement should I use to do that?
First of all, write the right SOQL group by count, and stop using the count field. Also, you need to write ORDER BY COUNT(Id) DESC, or you can write ORDER BY SUM(Count__c) DESC.