This is what i ended up doing
:
select
labels, [1],[2]
from(
select
*
,case when labels = 'Date' then 1
when labels = 'Loans' then 2
When labels = 'Dials Attempted' then 3
when labels ='DPL' then 4
when labels = 'Abandoned' then 5
when labels = 'Contacts' then 6
when labels = 'Success' then 7
when labels ='Conversion' then 8
end rownum
from
(
select
convert(varchar, Columnno ) Columnno
,convert(varchar, dt ) Date
,convert(varchar, Loans ) Loans
,convert(varchar, [Dials Attempted]) 'Dials Attempted'
,convert(varchar, dpl) DPL
,convert(varchar, aband) Abandoned
,convert(varchar, contact) Contacts
,convert(varchar, success) Success
,convert(varchar, conv) Conversion
--,case when dt is not null then 1
from
data
) sourcetable
unpivot ( [Data] for labels in (Date,Loans, [Dials Attempted], DPL, Abandoned, Contacts, Success, Conversion ) ) pivots) sourced
pivot( max(Data) for Columnno in ([1],[2])) pvt
order by rownum
This is what it produced
