SQLFiddle Link
I\'ve got an SQLite database with a bunch of test/exam questions. Each question belongs to one question category.
Basically what you are looking for is select top N max values. I spend 3-4 hours in the morning for searching it. ( still i haven't success in it, you may need to wait few more hours ).
For the temporary solution you can use group by option as follows,
String strQuery = "SELECT * FROM so_questions group by category_id;";
the output is as follows,
will be back with exact your requirement.