Jump to content

Selecting Top N Records For Each Country.


Guest Sunflash
 Share

Recommended Posts

Guest Sunflash

Hey guys, it's been awhile since I've touched SQL, so I'm a little rusty. I have a table of over 50,000 cities, the table contains a fields for the Country, City Name, and Population. My goal is to create a query that will select each countries 15 most populated cities and list them in order. It seems like it should be simple enough, but for whatever reason I can't figure out what to do. It was simple to make a query to sort the table of cities by country, and than by population. But I don't want oor need all 50,000 fields listed, I would like to get the number of returned fields down to about 2000-4000.

SELECT *FROM CitiesORDER BY Country, Population DESC;

Any guidance on where to look for a solution would be very helpful!

Edited by Sunflash
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...