Jump to content

Selecting Top N Records For Each Country.


Guest Sunflash

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!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...