Experts,
I've a table with the following rows
Month Yr a b c
JAN 2016 1 2 3
DEC 2015 4 5 6
NOV 2015 7 8 9
......
And I need to pivot it to the following
Month NOV DEC JAN
a 7 4 1
b 8 5 2
c 9 6 3
The pivot query I'm using is below
Select *
From (Select Month , a, b, c
From dbo.table) s
pivot
(
sum(a)
for Month in ([JAN],[FEB],[MAR],[APR],[MAY],[JUN],[JUL],[AUG],[SEP],[OCT],[NOV],[DEC])
) P;
And I'm getting the following results which is not what I want.
b c JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
0 0 0 0 0 0 0 0 0 0 0 0 0 0
Can anybody suggest what I'm doing incorrectly? Or assist with the right answer?
Thanks.
The column names are not in right order? Does MAX(Value) has anything to do with it.