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
WildManWildMan 

SELECT Name, Amount, AccountId FROM Opportunity WHERE CALENDAR_YEAR(CreatedDate) = 2019 ORDER BY Amount DESC

I would like to rank my result !
Rank1 for the highter amount value
Rank2 for an other value
Rank3 and so on
Saad J 5Saad J 5
Hi WildMan,

See the below code that gives rank, I have used 2020, you can use 2019 there. If is it the requirement, then mark it as the best answer, that will help others too.
List<Opportunity> o = [SELECT Name, Amount, AccountId FROM Opportunity WHERE CALENDAR_YEAR(CreatedDate) = 2020 ORDER BY Amount DESC];
Integer ranks = 0;
for(Opportunity rank: o){
    ranks++;
    System.debug('Rank'+ranks+''+rank.Name+''+rank.Amount);
}