​SELECT name, genre, size, ntile(4) over(order by size desc) from game below explains what happens if there are rows that are non divisible by number of groups. https://learnsql.com/track/advanced-sql/course/window-functions/rank-functions/ranking-functions/ntile-practice eg says you have 11 records and we want 5 groups, then first group will get 3 records and remaining will get 2 records