Row to column for grid

Database

Row to column for grid

I have data like below

SL,ID,C1,C2,C3,C4,C5
1,1,10,20,30,40,50
1,2,100,200,300,400,500
1,3,5,15,25,35,45
...
1,11,1,2,3,4,5

2,1,10,20,30,40,50
2,2,100,200,300,400,500
2,3,5,15,25,35,45
...
2,11,1,2,3,4,5
...

We will get 11 (ID value) rows for each SL column & C1 to C5 is a column name & it may vary to C1 to C(n) & the output want in below format:

SL,Column name,ID1,ID2,ID3,...,ID11
1,C1,10,100,5,...,1
1,C2,20,200,15,...,2
1,C3,30,300,25,...,3
1,C4,40,400,35,...,4
1,C5,50,500,45,...,5

2,C1,10,100,5,...,1
2,C2,20,200,15,...,2
2,C3,30,300,25,...,3
2,C4,40,400,35,...,4
2,C5,50,500,45,...,5
...

any help, thanks

1 REPLY

Re: Row to column for grid

in the source table, all ID=1 sit in tbl_1 & all ID=2 will sit in tbl_2 etc.. all ID=11 will sit tbl_11 & all tbl_<xx> will contains same no of rows & same number of columns except C1 to C(n) content change, also each tbl_<xx> contains between 1MM to 40 MM rows, using these 11 tables to store output in target format.., thanks