I am trying to convert work done MS Excel into t-sql code. Column A is my index. I need to combine the values associate with index =1 in column C, each separated by a soft break.
In MS Excel I achieve this by placing this function in cell C2=IF(A2<>A1,B2,C1 & CHAR(10) & B2) and =IF(A2<>A3,1,0).
The combined functions on column C will concatenate of the values in column B, as the index in column 1 match. The function in column D will compare the values in column C until it finds an unique value. In cell D5, notice values from B2:B5 has been concatenated into a single cell.
If filter the worksheet where the values in column D =1, then I am able to get the desired result.
How can I make this happened in SQL?