function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Veera7Veera7 

How can write a Soql query group by lastmodifieddate

Shailesh DeshpandeShailesh Deshpande
You cannot. LastModifiedDate is not a groupable field.

When you’re creating SOQL queries with the GROUP BY clause, there are some considerations to keep in mind.
  • Some object fields have a field type that does not support grouping. You can't include fields with these field types in a GROUP BY clause. The Field object associated with DescribeSObjectResult has a groupable field that defines whether you can include the field in a GROUP BY clause. For egLead.LastModifiedDate.getDescribe().isGroupable() returns false.
If you wish to group using LastModifiedDate, you will have to develop a custom logic, like have map with key as date and value as list of records modified on that date.

Thanks,
Shailesh.