0

For example, I have those data:

username,credits
user1,20
user2,30
user3,20
user4,20
user5,10
user6,30
...

they may have many many rows.(let's say 1000 )

but the credits group is limit.( let's say no more than 10)

How to make a group by query and pick up few data from each group? eg: 3 for each credit, the result is expected as bellow:

user5,10
userX,10
userY,10

user1,20
user3,20
user4,20

user2,30
user6,30
userZ,30

...

How to do that?

Niuya
  • 428
  • 1
  • 5
  • 14
  • possible duplicate of [Get top n records for each group of grouped results](http://stackoverflow.com/questions/12113699/get-top-n-records-for-each-group-of-grouped-results) – Kenan Zahirovic Sep 07 '14 at 08:31
  • Should be a little different with that one. That one, the groups is fixed to be 1 or 2 or 3, but my example ,the credits is not fixed. It may be 10,20,30, but also may be 11,22,30... .Also that question is too complex for me to understand. :( – Niuya Sep 08 '14 at 14:54

0 Answers0