Skip to content
Advertisement

Sql limit record grouped

I have a table ‘Players’ In this table the columns are 'ID','surname','nation' I need a query and result must shows a list of Players by nations limited by 4 for nations Ex Table players

Resultset

Advertisement

Answer

With row_number() window function:

See the demo.
Or if your version of SQLite does not support window functions:

See the demo.
Results:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement