Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 adding columns

Author  Topic 

clewis99
Starting Member

3 Posts

Posted - 2007-03-05 : 23:52:24
Is there a way to add two columns (with numbers) that have already been aliased? I summed the two columns separately, and also want to display a third colum that show the sum of the two already summed columns. Any help is appreciated. thanks.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-06 : 00:24:00
[code]
select col1, col2, col3 = col1 + col2
from (
< your existing query here, example : >
select col1 = sum(...), col2 = sum( ... )
from sometable
where somecondition = somevalue
) a
[/code]


KH

Go to Top of Page
   

- Advertisement -