Reputation: 5446
I have this table like this:
Name; Amount1, Amount, Rate1, Rate2
Test; 1000; 2000; 1.0; 2.0
I want to display into:
Parameter; Amount1; Rate1; Total
'Parameter 1'; 1000; 1.0; 1000
'Parameter 2'; 2000; 2.0; 4000
BTW ... I am using SQL2K5. All I can think of is CURSOR. Any other solution in elegant way?
Thanks
Upvotes: 0
Views: 32
Reputation: 1632
select *, Amount*rate Total from(
select n parameter, case when n='parameter1' then amount1 else amount2 end Amount,
case when n='parameter1' then rate1 else rate2 end rate
from tests t cross join (select 'parameter1' as n union all select 'parameter2') x
) y
Upvotes: 1