आपने यह निर्दिष्ट नहीं किया कि आप शीर्ष 10 की रैंकिंग कैसे कर रहे हैं, इसलिए मैं मान रहा हूँ कि उच्चतम संख्याएँ उच्चतर हैं?
With TopItems As
(
SELECT C.CountryID AS CountryID
, C.CountryName AS Country
, Count(FirstName) AS Origin
, ROW_NUMBER() OVER( ORDER BY Count(FirstName) DESC ) As Num
FROM Users AS U
JOIN Country AS C
ON C.CountryID = U.CountryOfOrgin
GROUP BY C.CountryName, C.CountryID
)
Select CountryId, Country, Origin
From TopItems
Where Num <= 10
Union ALL
Select 0, 'Others', Sum(Origin)
From TopItems
Where Num > 10