Have a table like this:
| col1 | col2 |
---------------
| 1 | a |
| 2 | b |
| 3 | a |
| 4 | a |
| 5 | a |
| 6 | b |
| 7 | a |
| 8 | b |
I would like to select rows randomly that have a
and b
but limit the result to 2 rows for each a
and b
, like this:
| col1 | col2 |
---------------
| 3 | a |
| 5 | a |
| 2 | b |
| 8 | b |
I'm probably missing something, but I cannot figure out how to do it.