You need to sign in to do that
Don't have an account?
aka
How to display AggregateResult data in visualforce page.
public class in the
AggregateResult [] gr =
[select count (name) kazu, sum (Field5__c) ttl
from CustomObject3__c
group by Field4__c
order by Field4__c DESC];
The results of the above
<apex:pageBlock>
Please tell me how do I know what I want to use the display.
help me!
Below is the sample code to display Aggregate Result on VF page :
Integer TotName=0;
AggregateResult [] gr = [select count (name) kazu, sum (Field5__c) ttl from CustomObject3__c group by Field4__c order by Field4__c DESC];
for (AggregateResult ar : gr)
{
System.debug('Total Name' + ar.get('expr0'));
TotName = TotName + ar.get('expr0');
Use {!TotName} on VF page to display the Total Name value.
All Answers
Below is the sample code to display Aggregate Result on VF page :
Integer TotName=0;
AggregateResult [] gr = [select count (name) kazu, sum (Field5__c) ttl from CustomObject3__c group by Field4__c order by Field4__c DESC];
for (AggregateResult ar : gr)
{
System.debug('Total Name' + ar.get('expr0'));
TotName = TotName + ar.get('expr0');
Use {!TotName} on VF page to display the Total Name value.
Thank you Pradeep Navatar
But
TotName = TotName + ar.get ('expr0');
In the above formula
Error (Arithmetic expressions must use numeric arguments) is becoming?
I tried in another example,
Error (Arithmetic expressions must use numeric arguments) will be.
System.debug('kazu' + ar.get('kazu'));
System.debug('ttl' + ar.get('ttl'));
nen = string.valueOf(ar.get('mm'));
kazu = integer.valueOf(ar.get('kazu'));
ttl = Double.valueOf(ar.get('ttl'));
のようにコーディングしましたら
エラーは出なくなりました。
ありがとうございます