You need to sign in to do that
Don't have an account?
Olivia Davis
SOQL Help - GROUP BY and MAX
Error: Field must be grouped or aggregated: et4ae5__Contact_ID__c. I need to return the Contact ID and the max DateOpened grouped by Contact. I don't think et4ae5__Contact_ID__c is a groupable field. This is in workbench SOQL query. Please help!
SELECT MAX(et4ae5__DateOpened__c),et4ae5__Contact_ID__c
FROM et4ae5__IndividualEmailResult__c
WHERE et4ae5__Opened__c=TRUE
GROUP BY et4ae5__Contact__c
This is the one I started with:
SELECT et4ae5__DateOpened__c,et4ae5__Contact_ID__c
FROM et4ae5__IndividualEmailResult__c
WHERE et4ae5__Opened__c=TRUE
ORDER BY et4ae5__DateOpened__c DESC
LIMIT 1
GROUP BY Contact_ID__c
SELECT MAX(et4ae5__DateOpened__c),et4ae5__Contact_ID__c
FROM et4ae5__IndividualEmailResult__c
WHERE et4ae5__Opened__c=TRUE
GROUP BY et4ae5__Contact__c
This is the one I started with:
SELECT et4ae5__DateOpened__c,et4ae5__Contact_ID__c
FROM et4ae5__IndividualEmailResult__c
WHERE et4ae5__Opened__c=TRUE
ORDER BY et4ae5__DateOpened__c DESC
LIMIT 1
GROUP BY Contact_ID__c
Your first request should be correct.
Is et4ae5__Contact_ID__c a formula field?
Checking for groupable:
https://workbench.developerforce.com/describe.php
info > Standard & Custom Objects : Fields > groupable
Regards