So I've added a count field to the object and based on your advice I built this SOQL, how can I now order the result based on the SUM?
List<AggregateResult> result = [SELECT Searched_Phrase__c, SUM(Count__c) sum FROM Portfolio_Catalog_Searched_Term__c GROUP BY Searched_Phrase__c limit 5];
I'm looking for help on what is the right way to write this SOQL: I have an object that holds the phrases that were entered into a search box (search terms), each record represents one search that was made. I want to count how many searches were made for each phrase and order this in a descending order.
I want to use this to show on a VF page the top 5 searched.
What is the right SOQL statement for this?