I have to pull data from a Salesforce database and get a count of the number of times each category appears. Currently, I have it pulling a list of the categories and then I use a perl script to filter through them and count, etc... but I would like to do it all through the SQOL query. This is what I'm trying currently, but it isn't working:
Select Category__c, COUNT(Category__c) FROM Case WHERE CreatedDate = THIS_MONTH GROUP BY Category__c
I keep getting the error "Grouped field should not be aggregated: Category__c"
I'm new to SQL/SOQL so I'm sure there is a simple solution for this. I've searched for similar questions but haven't found a solution yet...
A few other things I would like to do if possible:
- Return a row with "Total:" and the total count of categories
- Order the results in descending order
Any help is appreciated!