I am using Microsoft SQL server. I have a select statement that has number of columns queried from joining more than 4 tables, and the result table is shown as below,
| column1 | column2 | column3 | column4 |
| ------------ | ------------ | ------------ | ------------ |
| 1 | File1 | Table1 | Column1 |
| 1 | File1 | Table1 | Column2 |
| 1 | File1 | Table2 | Column1 |
Here, the values of Column4 are distinct that must be grouped and the result that I require is,
column1 | column2 | column3 | column4 |
---|---|---|---|
1 | File1 | Table1 | Column1, Column2 |
1 | File2 | Table2 | Column1 |
1条答案
按热度按时间91zkwejq1#
you can use STRING_AGG
base Data