Friday, March 9, 2012

Oposite to cross tab?

I need to format the table shown :

Estimate | Quantity | Admin_can | Amind_am | Manu_fix | Manu_var
--------------------
5 | 1000 | .10 | 0.10 | 0.75 | 0.7

as the following :

Estimate | Variable | Quantity | Value | Total
----------------
5 | Admin_ca | 1000 | 0.1 | 100
5 | Admin_am | 1000 | 0.1 | 100
5 | Manu_fix | 1000 | 0.75 | 750
5 | Manu_var | 1000 | 0.7 | 700

I need to do this so it would be the correct format for a report. Can anyone suggest how to do this? I need to create a view with this format, so speed is
probably an issue?

Mike Bselect Estimate, 'Admin_ca' as Variable, Quantity, Admin_can as Value, Quantity * Admin_can as Total
UNION
select Estimate, 'Admin_am' as Variable, Quantity, Amind_am as Value, Quantity * Amind_am as Total
UNION
select Estimate, 'Manu_fix' as Variable, Quantity, Manu_fix as Value, Quantity * Manu_fix as Total
UNION
select Estimate, 'Manu_var' as Variable, Quantity, Manu_var as Value, Quantity * Manu_var as Total

No comments:

Post a Comment