I have a ms sql database table where I want to find all the unique combinations of categories (CatId) that subscribers (SubId) have signed up for.
SubId CatId Cat
4 39 Google Play
4 40 Kobo
4 43 Other
5 39 Google Play
5 43 Other
7 49 Amazon
7 39 Google Play
7 40 Kobo
6 39 Google Play
6 40 Kobo
6 43 Other
8 49 Amazon
8 39 Google Play
8 40 Kobo
9 38 Barnes & Noble
9 41 Smashwords
The output would hopefully be like: (Where groupId is counter for the combinations)
GroupId CatId Cat Occurances
1 39 Google Play 2
1 40 Kobo 2
1 43 Other 2
2 39 Google Play 1
2 43 Other 1
3 49 Amazon 2
3 39 Google Play 2
3 40 Kobo 2
4 38 Barnes & Noble 1
4 41 Smashwords 1
Any help would be appreciated