I have a list of person by nationality. These people must be grouped or divided if their number is greater or less than 4 in group of max 4 person with same nationality.
Nationality | Number |
---|---|
Italian | 7 |
Franch | 2 |
Franch | 3 |
English | 2 |
English | 1 |
Spanish | 9 |
The result that I wont is :
Nationality | groupOf |
---|---|
Italian | 4 |
Italian | 3 |
franch | 4 |
franch | 1 |
English | 3 |
Spanish | 4 |
Spanish | 4 |
Spanish | 1 |
The goal is to get groups of 4 or less. For example if I have 41 rows of Swedish with Number=1 the goal is 10 rows of Swedish with GroupOf = 4 plus one row with groupOf = 1.