There are a few different issues with your code.
- All fields in your
SELECT clause must be in your
GROUP BY clause or wrapped in an aggregate operation.
- You can't
GROUP BY a
Datetime field (chances two records share the same value are extremely low). If you want to count just the date portion, use
- You have a trailing
. character in your query. If that is not a typo and you did include it, it will cause your query to fail.
The following query should work, for example:
Description, DAY_ONLY(CreatedDate), count(Id),
WHERE WhoId = :contactId
GROUP BY Description, DAY_ONLY(CreatedDate)
If you really need values from the other fields, you should question why you are grouping in the first place. If you want to include them in your
SELECT clause, you need to either
GROUP BY them as well or decide on the proper aggregation method to apply to them.