I'm trying to figure out the best way to get a count of the number of kids per location.
Here is the current query that works and populates my VF page.
SELECT puLocation__r.Name LocationName,
puLocation__r.notes__c LocationNotes,
puLocation__r.Milk_Location__c MilkLocation,
puLocation__r.Location_type__c LocationType
FROM Child_Consent_Form__c
GROUP BY puLocation__r.Name,
puLocation__r.notes__c,
puLocation__r.Milk_Location__c,
puLocation__r.Location_type__c];
This query below worked in the query editor but the forum helped me figure out that this wasn't going to work on my VisualForce page because of the count(). The count(Name) gave me the total number of kids per location.
//Records = [SELECT puLocation__r.Name, puLocation__r.Milk_Location__c, puLocation__r.notes__c, COUNT(Name) from Child_Consent_Form__c GROUP BY puLocation__r.Name, puLocation__r.Milk_Location__c, puLocation__r.notes__c ];
Here is the original thread.
Unknown property 'SObject. - Why can't I display the object?
My problem is that I can't figure out how to get around this.
SELECT Name, (SELECT Id FROM Child_Objects__r) FROM Parent_Object__c WHERE..., and then in Visualforce obtain the count with{! parent_object.Child_Objects__r.size }