I’ve been looking for a way to show one column in multiple rows, one cell. The content of it separated by comma’s.
For example, in stead of:
ProjectID Name count ------------------------------------- 2 Technical Services 31 1 Security Services 32 7 Technical Services 32
I would like the result of my query to look like this:
Name Label --------------------------- Technical Services 31,2 Technical Services 32,7 Security Services 32,1
I also want the result of my query to look like this: (like Group_Concate
in MySQL)
Name Label ------------------------------- Security Services 32,1 Technical Services 31,2: 32,7
Try this:
Result
See this SQLFiddle
If you want to group by
Name
(Something likeGroup_Concate
in MySQL) there is no any method for it in SQL Server. It's just a logic behind it.So try this:
So the result will be
See this SQLFiddle