Using LIMIT
within GROUP BY
to get N results per dynamic group
Hello everyone, firstly I read about questions like this problem. But didn't get the solution. All of this SQL's are designed for static columns. But I have dynamic columns.
Table:
id Name Group Level
2 Jonathan A 5
5 David A 10
6 Alex C 10
7 Kemal A 71
8 John D 21
9 Celin F 100
12 Alexis G 15
13 Noone A 23
I want to get the first 2 highest Level
from each group.
But query must be dynamic because there will be more Groups, which is where I am stuck.
Solutions I tried:
- Select the top N rows from each group Not giving true result it's broken.
- Only work in static columns.