function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Can you elaborate on how to calculate Annual revenue? Do we have some formula for this ?
Thank you
try this code...
public class AccountBatchClass implements Database.Batchable<sobject>, Database.Stateful
{
decimal sum;
public Database.QueryLocator start(Database.BatchableContext bc)
{
return Database.getQueryLocator('select AnnualRevenue from Account where CreatedDate=Today');
}
public void execute(Database.BatchableContext bc, List<Account> accList)
{
AggregateResult[] res=[Select SUM(AnnualRevenue)tot_annual from Account where CreatedDate=Today];
for(AggregateResult ag:res)
{
sum=(Decimal)ag.get('tot_annual');
}
}
public void finish(Database.BatchableContext bc)
{
System.debug('Sum of Annual Revenue : '+sum);
}
}
in Annonymous Window...
AccountBatchClass ac=new AccountBatchClass();
Id batchId = Database.executeBatch(ac, 200);
Id batchId1 = Database.executeBatch(ac, 200);
Id batchId2 = Database.executeBatch(ac, 200);
Id batchId3 = Database.executeBatch(ac, 200);
and check batch apex in logs.
Hope it will be helpful for u.