The above query results in an error
SELECT MAX(CreatedDate),OldValue,NewValue FROM LeadHistory GROUP BY OldValue,NewValue
The error :
ERROR at Row:1:Column:69 field 'OldValue' can not be grouped in a query call
Can someone explain this error ?
If you execute this code in "Developer Console"/"Debug"/"Open Execute Anonymous Window":
you will see that
So this is a limitation of the platform, and you will have to query the values ungrouped and use Apex code to achieve your desired logic instead.