My data as follow:
> mydata
month count1 count2 count3
1 201301 100 110 50
2 201302 150 160 60
3 201303 200 210 50
My expected data like this:
>final data
count_all 201301 201302 201303
1 count1 100 150 200
2 count2 110 160 210
3 count3 50 60 50
How can I get the result using SQL? I know PIVOT a little, but it seems there are some problems in the column name during my processing. I need an efficient way to resolve this problem. And I will execute such a query:
select * from final_data where count_all='count1'
So if not with this row-column transformation
, I don't know how to get a similar result.