mattyvx Posted January 4, 2010 Share Posted January 4, 2010 Hi, I have a member list stored in a database and each member must enter their city when joining. What i want to do is print a list of the top 5 cities that my members are from. The field the cities are stored in is aptly named "City". Any ideas would be appreciated! Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 4, 2010 Share Posted January 4, 2010 This will give you a result set of the top 5 cities and the number of users associated with each SELECT city, COUNT(city) as count FROM users GROUP BY city ORDER by count DESC LIMIT 0, 5 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.