Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Concatenating rows in a select horizontally...

$
0
0
Hi, Can you help me please? I'm using the SQL indicated below:[code="sql"]SELECT DISTINCT C.Field1 As 'Group', A.Field2 As 'Security Object' E.Field3 As 'User'FROM TableA AS AJOIN TableB AS B ON B.key1 = A.Key1JOIN TableC AS C ON C.Key1 = B.key2JOIN TableD AS D ON D.key1 = C.key2where A.Field1 = 'ObjectA'GROUP BY C.Field1, A.Field2, E.Field3[/code]Typical OutputGroup Security Object UserGroup1 ObjectA UserAGroup1 ObjectA UserBGroup1 ObjectA UserCGroup2 ObjectA UserEGroup2 ObjectA UserFGroup2 ObjectA UserHetc...I want to output something more like:Group Security Object UserGroup1 ObjectA UserA, UserB, UserCGroup2 ObjectA UserE, UserF, UserHetcHowever I'm having difficulties concatenating the user field in the horizontal form indicated. Can you help me please?I know there is lots about this online, but nothing is working properly :-(J.

Viewing all articles
Browse latest Browse all 3145

Trending Articles