I am trying to get the account which has the highest number of opportunities.
Tried below and getting all the accountids and it's related opportunity count. But how do I only get the account record with highest opportunity number count.
Use ORDER BY to get this result:
SELECT COUNT(Id), AccountId
FROM Opportunity
GROUP BY AccountId
ORDER BY COUNT(Id) DESC
LIMIT 1