I need to group data on the basis of two fields "description" and "createdDate" in soql.
Select Subject, WhatId, what.name, Owner.name, Owner.Id, IsVisibleInSelfService, ActivityDate, LastModifiedDate From Task Where whoId =: contactId Group By(Description, createdDate).
But it is throwing an error:
Unknown error parsing query
Best Answer
There are a few different issues with your code.
SELECT
clause must be in yourGROUP BY
clause or wrapped in an aggregate operation.GROUP BY
aDatetime
field (chances two records share the same value are extremely low). If you want to count just the date portion, useDAY_ONLY
..
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:
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 eitherGROUP BY
them as well or decide on the proper aggregation method to apply to them.