I have some data formatted like this:
Lane         Series
1            680
1            685
1            688
2            666
2            425
2            775
...
And I'd like to grab the highest n series per lane (let's say 2 for the sake of this example, but it could be many more than that)
So the output should be:
Lane         Series
1            688
1            685
2            775
2            666
Getting the highest series per lane is easy, but I can't seem to find a way to get the highest 2 results.
I use a MAX aggregate function with a GROUP BY to get the MAX, but there's no "TOP N" function as in SQL Server and using ORDER BY... LIMIT only returns the highest N results overall, not per lane.
Since I use a JAVA application I coded myself to query the database and choose what N is, I could do a loop and use a LIMIT and loop through every lane, making a different query each time, but I want to learn how to do it using MySQL.
 
     
     
     
    