MySQL Forums
Forum List  »  Newbie

Select N per Value
Posted by: Hubert Leitner
Date: December 12, 2011 05:16PM

Hi,

I have a table with Users from different cities etc.

I want to select Users by various criteria and at the same time I want to select only N Users per a specific criteria (for example only N per city).

For example - I want to select two Users from each city that are 22 years old and have enterd their email address. So i would write "SELECT * FROM Users where age=22 and email!=''"; but I have no idea how I can limit it to two Users per City.


I think here someone had the same problem http://stackoverflow.com/questions/4688664/mysql-select-n-records-base-on-group-by , but I don't understand the results :(

It would be great if anybody could help me.

Thanks :)

Options: ReplyQuote


Subject
Written By
Posted
Select N per Value
December 12, 2011 05:16PM
December 12, 2011 06:04PM
December 13, 2011 06:06AM
December 13, 2011 12:10PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.