I have a table in sql with following data,
Bus_Type Invalid_Counts Valid_Counts Percentage
---------------------------------------------------------
General 721 1339 53.85
Inquiry 243 9301 2.61
Firm 553 1207 45.82
I want to use pivot and get the data in the following format,
Cols General Inquiry Firm
-------------------------------------------
Invalid_Counts 721 243 553
Valid_Counts 1339 9301 1207
Percentage 53.85 2.61 45.82
This is my query for pivot,
select * from
(select Bus_Type, Invalid_Counts, Valid_Counts, Percentage from #temp) a
pivot(max(Invalid_Counts) for Bus_Type in (General, Inquiry, Firm)) pv
which gives me following result and it is not what I want,
Valid_Counts Percentage Firm General Inquiry
-----------------------------------------------------------
1339 53.85 NULL 243 NULL
9301 2.61 NULL NULL 553
1207 45.82 721 NULL NULL
Any ideas will be appreciated and helpful.
Thanks.