public List<AcctSumList> getAccountSummary() {
list<AcctSumList> acctSummary = new List<AcctSumList>();
List<AggregateResult> getList = [SELECT Account.Name, sum(amount) TotalAmount FROM Opportunity GROUP BY Account.Name LIMIT 10];
for(AggregateResult agg : getList) {
String AccountName = (string)agg.get('Account.Name');
Double TotalAmount = (double)agg.get('TotalAmount');
acctSummary.add(new AcctSumList(AccountName, TotalAmount));
}
return acctSummary;
}
public class AcctSumList {
public String AccountName;
public double AccountTotal;
public AcctSumList(String AccountName, double AccountTotal) {
this.AccountName = AccountName;
this.AccountTotal = AccountTotal;
}
}
And the visualforce where I try and put it in a table
Thanks,<apex:pageBlockTable value="{!AccountSummary}" var="acct">
<apex:column value ="{!acct.AccountName}"/>
<apex:column value="{!acct.TotalAmount}"/>
</apex:pageBlockTable>

Hello,Try the code below: public List<AcctSumList> getAccountSummary() {
list<AcctSumList> acctSummary = new List<AcctSumList>();
List<AggregateResult> getList = [SELECT Account.Name, sum(amount) TotalAmount FROM Opportunity GROUP BY Account.Name LIMIT 10];
for(AggregateResult agg : getList) {
String AccountName = (string)agg.get('Account.Name');
Double TotalAmount = (double)agg.get('TotalAmount');
acctSummary.add(new AcctSumList(AccountName, TotalAmount));
}
return acctSummary;
}
public class AcctSumList {
public String AccountName { get; set; }
public double AccountTotal { get ; set; }
public AcctSumList(String AccountName, double AccountTotal) {
this.AccountName = AccountName;
this.AccountTotal = AccountTotal;
}
}
You have to expose your variables using gettters and setters to allow you retrieving and setting values.
Regards.Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.