In simple terms the table (t1) looks like this:
id hours dollars
-----------------------
abc 4 40
I'd like to get results from the table that looks like this:
abcHours 4 0
abcDollars 0 40
Thanks
In simple terms the table (t1) looks like this:
id hours dollars
-----------------------
abc 4 40
I'd like to get results from the table that looks like this:
abcHours 4 0
abcDollars 0 40
Thanks
You can unpivot with cross apply
:
select x.*
from mytable t
cross apply (values
(concat(id, 'Hours' ), hours, 0 ),
(concat(id, 'Dollars'), 0, dollars)
) as x(newid, hours, dollars)
You may try simple query, using operator Union:
Select 'abcHours' as abcHour, hours as Hour, 0 as dollar
Union all
Select 'abcDollars', 0, dollars