Limit
Not Started

Just as important as ordering things, can be limiting things. Putting a LIMIT on your SOQL statements let you specify the maximum number of records to return.

To grab any 4 Opportunities that are not closed we query like we normally would, and apply the LIMIT at the end.

SELECT Name, StageName FROM Opportunity WHERE IsClosed = false LIMIT 4

NameStageName
Dickenson Mobile GeneratorsQualification
United Oil Office Portable GeneratorsNegotiation/Review
Grand Hotels Kitchen GeneratorId. Decision Makers
United Oil Refinery GeneratorsProposal/Price Quote



Same is the case when we add order to things. We apply it all before we start to LIMIT things down. To find a single opportunity in review with the highest probability we first order, and then limit.

SELECT Name, StageName, Probability FROM Opportunity WHERE StageName = 'Negotiation/Review' ORDER BY Probability DESC LIMIT 1

NameStageNameProbability
United Oil Office Portable GeneratorsNegotiation/Review90



Challenge

Write a query that returns the Name and Expected Revenue of the top 10 opportunities with the highest expected revenue.