Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Group by Concatenation of rows in sql server

$
0
0

Hi

I have tables like below

USER TABLE

_________________________________________________

ID   | Name  | Date

-----------------------------------------------------------

1| A |

2| A |

3| A |

4| B |

5| C |

6| C |

------------------------------------------------------------

AND ROLE TABLE

--------------------------------------------------

ID| ROLE

--------------------------------------------------

1| ADMIN

2| PRJ MGR

3| LEAD

4| ADMIN

5 PRJ MGR

6| LEAD

and i want result like below

___________________________

NAME | ROLE

---------------------------------------------

A| ADMIN , PRJ MGR , LEAD

B| ADMIN

C| PRJ MGR, LEAD

i have used STUFF method but it concatenate the string if the id or unique value only in the same table not with other table

Thanks


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>