Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 15.Continents and Currencies From Subqueries and Joins
- WITH CTE AS
- (
- SELECT Countries.ContinentCode, Countries.CurrencyCode, COUNT(Countries.CurrencyCode) AS CurrencyUsage,
- DENSE_RANK() OVER(PARTITION BY Countries.ContinentCode ORDER BY COUNT(Countries.CurrencyCode) DESC) AS RN
- FROM Countries
- GROUP BY Countries.CurrencyCode, Countries.ContinentCode
- )
- SELECT ContinentCode, CurrencyCode, CurrencyUsage
- FROM CTE
- WHERE RN = 1 AND CTE.CurrencyUsage != 1
- ORDER BY CTE.ContinentCode
Add Comment
Please, Sign In to add comment