function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bryn JonesBryn Jones 

SOQL & Query on VF Question

I have a SOQL query from rollup helper and want to use it in a VF page.

the query is SELECT Opportunity__c , ExpectedRevenue FROM Opportunity WHERE isDeleted = false AND closedate = THIS_MONTH

this sums up the amount of the closed opps and i wnat to use it to show on a VF page.

Please help

Bryn
ShaTShaT
HI,

You want to display the sum ExpectedRevenue of all the opportunity in vf page.
if this is the case than you need to do the following.

public integer totalRevenue=0;

list<Opportunity>oppList=[SELECT Opportunity__c , ExpectedRevenue FROM Opportunity WHERE isDeleted = false AND closedate = THIS_MONTH];

for(Opportunity opp:oppList){

totalRevenue+=opp.ExpectedRevenue;

}

You can use this field in Visual force page.


Thanks
Shailu
Avidev9Avidev9
You can have a look at aggregate queries http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_agg_fns.htm