Output from CTE:
colName
-----------------------
branch1
branch1
branch1
unclassified
I want to convert the rows into columns like:
colName colName colName colName
---------------------------------------------
unclassified branch1 branch1 branch1
Please let me know the best approach for this.
Thanks in advance!!
Without seeing your full query I would suggest adding a
row_number()
to your CTE and then pivoting the data based on the row number:If you do not want to use the PIVOT function, then you could also use an aggregate function with a CASE expression: