I have a table called leaders
. in it I have id
,userid
,bmid
,reps
,rounds
,ts
. Basically I need to put the top ten unique users out of the table that have the most rounds
. Now each time someone enters their reps
,rounds
its as a pair so someone might have 12 rounds
13 reps
so if that is their max and it is within the top ten of all users then I need to pull that info plus their corresponding reps
. I thought I had this but it is actually pulling their max
rounds
and their max
reps
from different rows. What I have is below.
SELECT max(l.rounds) as rounds, l.reps, m.name, l.userid
from leaders l
inner join members m on m.id = l.userid
where m.genre = 'male' and l.bmid = 1
group by l.userid
order by rounds desc,reps desc
the join
is to the members
table to get some info on them.