Reputation: 1355
I have output from a SQL query in this format:
Now, I want my output to look like this instead:
Please guide me on the best possible solution. Thanks!
Upvotes: 1
Views: 191
Reputation: 1269763
I would do this as:
select v.*
from t cross apply
(values ('2012-2013', t.Delta2012_2013, t.Percent2012_2013),
('2012-2014', t.Delta2012_2014, t.Percent2012_2014)
) v(row, delta, percent);
It is unclear how to calculate the total. Is it a constant? Is it delta / percent
? In any case, you can add the appropriate calculation.
Upvotes: 3