Advertisement
dragonbs

Count Mountain Ranges

Sep 28th, 2023
1,079
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.29 KB | None | 0 0
  1. SELECT c.[CountryCode], COUNT(m.[MountainRange]) AS [MountainRanges]
  2. FROM [Countries] c
  3. JOIN [MountainsCountries] mc ON c.[CountryCode] = mc.[CountryCode]
  4. JOIN [Mountains] m ON mc.[MountainId] = m.[Id]
  5. WHERE c.[CountryName] IN ('United States', 'Russia', 'Bulgaria')
  6. GROUP BY c.[CountryCode]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement