I have results coming from a query in the below format
ID CODE
----------
1 abc
1 xyz
1 def
1 pqr
1 jkl
1 tuv
I want the results to be in the following format
ID CODE1 CODE2 CODE3 CODE4 CODE5 CODE6
---------------------------------------
1 abc xyz def pqr jkl tuv
I know this can be achieved using static PIVOT
query, but the issue I am facing is that the CODE
column can have unknown values and I want my column names to be fixed i.e. CODE1
, CODE2
and so on 'til CODE6
.
Can someone please help me out with this?
Any suggestions are welcome.
Thank you.