By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
| reasonid | team | total_by_team | location | total_by_location | division | total_by_division |
|---|---|---|---|---|---|---|
| 2 | A | 3 | L1 | 2 | null | 0 |
| 3 | B | 1 | L2 | 1 | D1 | 1 |
| 2 | A | 3 | L1 | 2 | D2 | 1 |
| 2 | A | 3 | L3 | 1 | D3 | 1 |
| reasonid | team | total_by_team | location | total_by_location | division | total_by_division |
|---|---|---|---|---|---|---|
| 2 | A | 3 | L1 | 2 | null | 0 |
| 3 | B | 1 | L2 | 1 | D1 | 1 |
| 2 | A | 3 | L1 | 2 | D2 | 1 |
| 2 | A | 3 | L3 | 1 | D3 | 1 |