I have a table with column names ExDescription,Code,Week00,QtySold. The column Week00 contains values such as Week1,week2,week3,week4 etc ... Week53.
Now, I need to write a query to print the Week00 values as Column names and its values from SUM(QtySold). I tried with something like below, but not getting to the result.
select * from week_report1
pivot (SUM (QtySold) for week_00 in ([Week1],
[Week2],
[Week3],
[Week4],
[Week5],
[Week6],
[Week7],
[Week8],
[Week9],
.........
[Week52],
[Week53])) as MaxIn
where Code in ('99');
I'm attaching excel pivot display of the desired output for better picture of what i want to do.
