I am trying to write a queryset operation that transforms the first table into the second table as efficiently as possible
This is the criteria:
For each name, how many unique schools are affiliated with it? Also, the exact names and schools are unknown beforehand.
Name | School |
---|---|
John | USC |
John | USC |
John | UCLA |
Adam | UCSD |
Adam | USC |
Name | num_unique_schools |
---|---|
John | 2 |
Adam | 2 |