pivot on multiple column sql server
I have below table and want to use pivot on multiple column using sum
aggregate.
Category Station1 Station2 Station3
-------------------------------------------------------------
Category1 5.26 6.25 7.28
Category2 4.22 5.00 6.00
Category3 5.00 4.00 8.00
Category1 4.00 7.00 9.00
Category2 2.00 5.00 8.00
And Want Output like
My_Station Category1 Category2 Category3
------------------------------------------------------------------------
Station1 Sum_of_Cat1 Sum_of_Cat2 Sum_of_Cat3
Station2 Sum_of_Cat1 Sum_of_Cat2 Sum_of_Cat3
Station3 Sum_of_Cat1 Sum_of_Cat2 Sum_of_Cat3
With Single Query. Not using any loop
Thanks
No comments:
Post a Comment