I need to do a group by cube on a related list. What I want is to display a list of added services groups and the distinct count across all completed inspections by package, and the matrix should have the groups along the y axis with the packages along the x axis. I'm getting an error Expecting '}' but was : 'for'
public class AddedServices3 {
public list<Inspection__c> inspections = [SELECT Id, (SELECT Added_Services_Group__c, Inspection_Package__c, Id
FROM Inspection_Services__r)
FROM Inspection__c
WHERE Status__c = 'Completed' AND Month_Since_Launch__c > 0];
for(Inspection__c i: [SELECT id(SELECT Id, Added_Services_Group__c, Inspection_Package__c FROM Inspection_Services__r) FROM Inspection__c]){
for(Inspection_Service__c addedservices : i.Inspection_Services__r){
public list<AggregateResult> listAr = new list<AggregateResult>(
[SELECT Added_Services_Group__c AddedService, count_distinct(id) cnt, Inspection_Package__c Package,
GROUPING(Added_Services_Group__c), GROUPING(Inspection_Package__c)
FROM Inspection_Service__c
GROUP BY CUBE (Added_Services_Group__c, Inspection_Package__c)]
);
}
}}
Inspection_Services__r
is not a type name (Inspection_Services__r services
).