Display an aggregate result on a visualforce page

The AggregateResult object is like a Map and so to access the values you need to use map syntax in the Visualforce:

<apex:column value="{!s['total']}"></apex:column>

PS

Here is a working example of using the map syntax:

<apex:page controller="MyController">
    <apex:pageBlock>
        <apex:pageBlockTable value="{!results}" var="r">
            <apex:column value="{!r['aaa']}"/>
            <apex:column value="{!r['bbb']}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

public with sharing class MyController {
    public AggregateResult[] results {
        get {
            return [select AccountId aaa, count(Id) bbb from Contact group by AccountId];
        }
    }
}

Tags:

Aggregate

Soql