Title: Group Specific Rows within Group By
Tags: sql-server
Question: I'm looking to combine some specific values in an aggregation query after the group by clause. If I have to hard code in that these specific examples need to be grouped, that should be ok.

So after the group by, we have sales by person which I would like to get to the lower image




Here is the accepted answer: You can use ```case```:

```select (case when salesperson in ('Luke', 'Bob', 'Luke/Bob') then 'Luke/Bob'
             else salesperson
        end) as salesperson,
       sum(sales)
from t
group by (case when salesperson in ('Luke', 'Bob', 'Luke/Bob') then 'Luke/Bob'
               else salesperson
          end);
```



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:11/10/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<sql-server>', 'Title': 'Group Specific Rows within Group By', 'ViewCount': 29, 'id': 47215055, 'user_AboutMe': None, 'user_AccountId': 12172287.0, 'user_DisplayName': 'cwarden', 'user_Reputation': 13.0, 'user_Views': 5.0, 'user_id': 8886557.0}}