So, I have table similar to:
sn color value
1 red 4
2 red 8
3 green 5
4 red 2
5 green 4
6 green 3
Now I need the latest 2 rows for each color, eg:
2 red 8
4 red 2
5 green 4
6 green 3
How to do it, other than using separate query for each color?
Thanks
Best Answer
With MySQL 8
Using MySQL < 8
You need to use their special variables.. something like this