hey guys I have a small issue in SQL I have a table shown below each name has at least 2 emails shown in the table I want an output in which the name is in one row and all emails side by side if any solution help out Table col1 | col2 __________________________ abhi | xyz@email abhi | abc@email abhi | rst@email ragu | str@email ragu | pqr@email expected output: col1 | col2 abhi | xyz@email,abc@email,rst@email ragu | str@email,pqr@email[enter image description here][1] [1]: https://i.stack.imgur.com/f29mF.png
SELECT DISTINCT col1, LISTAGG(col2, ',') WITHIN GROUP (ORDER BY col2) OVER (PARTITION BY col1) FROM Table
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)