Here is my VF page:
<apex:page controller="CurrentWeekDY">
<apex:pageBlock title="Delivery WTD">
<apex:pageBlockTable value="{!DelSumOut}" var="dy">
<apex:column value="{!dy.Campaign}" headerValue="Campaign" />
<apex:column value="{!dy.Delivery}" headerValue="Delivery" />
</apex:pageBlockTable>
</apex:pageBlock>
And here is my controller:
I would really appreciate any help!!Thanks,public class CurrentWeekDY {
public class DelSum {
public String Campaign {get; set;}
public String Delivery {get; set;}
public DelSum(string c, string d) {
this.Campaign = c;
this.Delivery = d;
}
}
public List<DelSum> DelSumList = new List<DelSum>();
public List<DelSum> getDelSumOut() {
AggregateResult[] AgR = [SELECT Camp__c, SUM(Spend__c) FROM TL_Client__c WHERE CWDelivery__c = TRUE GROUP BY ROLLUP(Camp__c) ORDER BY Camp__c];
for (AggregateResult DYList : AgR) {
DelSumList.add(new DelSum(String.valueOf(DYList.get('Camp__c')), String.valueOf(DYList.get('expr0'))));
}
return DelSumList;
}
}
John
So, if anyone is still looking for an answer to this question, make sure you add an ORDER BY clause that targets your GROUP BY field and add NULLS LAST. Here's an example:
SELECT StageName, COUNT(Id), FORMAT(SUM(Amount)), FORMAT(AVG(Amount))
FROM Opportunity
GROUP BY ROLLUP (StageName)
ORDER BY StageName NULLS LAST
This will ensure the "Total" row is last (since the StageName in the case above will be null on that row -- and by default, nulls come first unless NULLS LAST is specified).