Monday, 2 September 2013

Selecting distinct values for multiple columns in Single Row

Selecting distinct values for multiple columns in Single Row

I have a SQL table called "calculation" that looks like this:
id | InsulationMaterialId1 | InsulationMaterialId2| InsulationMaterialId3
| InsulationMaterialId4
-----------------------
1 | 34 | 45 | 34 | 50
2 | 34 | 78 | 35 | 51
3 | 35 | 32 | 34 | 52
4 | 36 | 30 | 34 | 53
5 | 40 | 39 | 34 | 34
6 | 41 | 34 | 34 | 56
7 | 42 | 36 | 34 | 53
In these table , we have 4 columns with insulation ids , I want to get
unique insulation ids in one single column with ',' separated means Output
like this :-
id | InsulationMaterialIds
-----------------------
1 | 34,45,50
2 | 34,78,35,51
3 | 35,32,34,52
4 | 36,30,34,53
5 | 40,39,34
6 | 41,34,56
7 | 42,36,34,53

No comments:

Post a Comment