I have a picklist field 3 values Like Red,Blue,White. There are 50 records in the object with different picklist values. Now I need a query – How many records with Picklist value – Red and AND how many records with Picklist value – Blue and same for the third value – White?
It should show like Picklist – Red-15 ,Picklist – Blue-10, Picklist – White-25. If it is not Possible then need a query to show all records picklist value wise?
Best Answer
This is a type of "aggregate result" query, and it looks like this:
The output would look like this:
You can summarize up to 2,000 values this way, which is more than enough for a single picklist.
You can read more about it in GROUP BY | SOQL and SOSL Reference.