I have records with same values in custom field, Unique_Name__c
. On a Visualforce Page
, I have to display records grouped by Unique_Name__c
.
Unique_Name__c
is custom field on OpportunityLineItem
populated using a Workflow Rule
from Product2
object (product name).
So I have a query
SELECT Id, Unique_Name__c
FROM OpportunityLineItem
GROUP BY Unique_Name__c
When I run this, I get an error saying:
MALFORMED_QUERY: Field must be grouped or aggregated: Id
When I change query to
SELECT Id, Unique_Name__c
FROM OpportunityLineItem
GROUP BY Id
I get the following error:
MALFORMED_QUERY: Field must be grouped or aggregated: Unique_name__c
Can anyone please help me figuring this out?