tags:

views:

33

answers:

1

Query:

SELECT 'SUMS' AS [Desc], SUM(PriceN) AS Nett, SUM(PriceG) AS Gross 
FROM Resources  

gives me a resultset:

Desc     Nett   Gross  
-------- ----   ------   
SUMS     515.00 621.55  

I need a resultset which looks like this:

Desc   Value  
----   -----  
Nett   515.00  
Gross  621.55

I was struggling with pivot statement, but unfortunately I cannot make it to work.
This is only part of the problem, because I have to be able to add more sums to select statement.
I'm looking for any clue, how to deal with this problem. Thanks in advance for any help.

+4  A: 

This should work for you:

SELECT 'Nett' AS [Desc], SUM(PriceN) AS Value FROM Resources
UNION ALL
SELECT 'Gross' AS [Desc], SUM(PriceG) AS Value FROM Resources
Mark Byers
Thx... simplicity is power! :D
Michal Krawiec