Is it possible to add a group name to a grouped set in T-SQL
Select Class, Category, Gender,Count(1) as Total, 'GroupNameHere' from PersonTable
Group By Class, Category, Gender
I want that every grouped set is given a new name like mentioned below
Actual Table
Name | Class | Category | Gender | Address | ZipCode
----------------------------------------------------------------------------
ABC | 2 | Cat 1 | M | Some Add.. | 10125
XYZ | 2 | Cat 1 | M | Some Add.. | 20554
AFF | 3 | Cat 3 | M | Some Add.. | 24525
ASD | 7 | Cat 6 | F | Some Add.. | 18892
GDS | 7 | Cat 6 | F | Some Add.. | 17745
Output
Class | Category | Gender | Total | GroupName
----------------------------------------------------------------------------
2 | Cat 1 | M | 2 | Group 1
3 | Cat 3 | M | 1 | Group 2
7 | Cat 6 | F | 2 | Group 3