I have the following table in SQLite:
category | userId | points
----------|--------|---------
25| 522| 380
25| 487| 350
25| 142| 100
25| 385| 500
26| 521| 300
26| 524| 100
26| 366| 880
43| 123| 310
43| 587| 340
43| 935| 90
43| 625| 85
I want to select the TOPs points of each category and have already tried in several ways without success.
For example:
Select distinct (category), userId, points
from RecordPoints order by category, points DESC
Expected outcome:
category | userId | points
----------|--------|---------
25| 385| 500
26| 366| 880
43| 587| 340
But the query result is not as expected as above.
If you want the top value in each category, then you can use
where
and a correlated subquery: