I have table like below:
|Group|User|
| 1 | X |
| 1 | Y |
| 1 | Z |
| 2 | X |
| 2 | Y |
| 2 | Z |
| 3 | X |
| 3 | Z |
| 4 | X |
I want to calculate intersections of groups: 1&2, 1&2&3, 1&2&3&4. Then I want to see users in each intersection and how many of them are there. In the given example should be:
1&2 -> 3
1&2&3 -> 2
1&2&3&4 -> 1
Is it possible using SQL? If yes, how can I start?
On a daily basis I'm working with Python, but now I have to translate this code into SQL code and I have huge problem with it.