You need to sign in to do that
Don't have an account?
Problem with Aggregate SOQL Query
I'm trying to count a group of records and get the total records by account and then put the account id and the number of child records into a map. I keep getting an "incompatible key type for map" on compile and I'm not sure why. Hopeing somone has an idea!
If I take the map out and just look at the debug, it's pulling out the Account id as a string...
Map<String, Integer> acctCalls = new Map<String, Integer>(); List<AggregateResult> r = [SELECT Account_vod__r.Name acctid, COUNT(id) totalCalls FROM Call2_vod__c GROUP BY Account_vod__r.Name]; for(AggregateResult i : r){ acctCalls.put(i.get('acctid'), i.get('totalCalls')); system.debug(' account>>> ' + i.get('acctid') + 'number of calls>>> '+i.get('totalCalls')); }
Thanks,
JoAnn
Try this.
All Answers
Try this.
Thanks! I got so wrapped up in the key type that I couldn't see the forest for the tress on this one. Your suggestion worked perfectly!
JoAnn