You need to sign in to do that
Don't have an account?
Sonu06
How to Find Second Maximum value of Number field??
Hey guys , I am beginner to salesforce, my reqirement is I have to find the Second Maximum amount of oppurtunity using Soql query,, so what will be the query ??
You can achieve this with order by, limit and offset.
Explanation:
- ORDER BY Amount DESC NULLS LAST (get the opportunities in the amount order from highest to lowest)
- LIMIT 1 (get only one record)
- OFFSET 1 (skip the highest amount opportunity)
Regards,MKR
All Answers
You can achieve this with order by, limit and offset.
Explanation:
- ORDER BY Amount DESC NULLS LAST (get the opportunities in the amount order from highest to lowest)
- LIMIT 1 (get only one record)
- OFFSET 1 (skip the highest amount opportunity)
Regards,MKR
Didn't understand your problem , are you saying you want to query the second opportunity amount , then you can use the order by clause to sort and get the second record or opportunity.
list<Opportunity> lstOpportunity = [Select amount from opportunity order by opportunity desc];