I have a table called categories that has 3 columns: id, name, parent_id
.
ID name group_id
== == ==
1 haim 1
2 gil 2
3 alon 1
4 idan 1
5 shai 3
6 adi 2
7 itay 3
8 aviram 1
9 lioz 3
10 amit 2
11 ben 2
12 eran 1
i need to select 2 rows of each group_id
in one query so the result would be:
ID name group_id
== == ==
1 haim 1
3 alon 1
2 gil 2
6 adi 2
5 shai 3
7 itay 3
it's very important that it will also be sorted by group_id
.
Thanks!