How do I add values from two separate queries in SQL
        Posted  
        
            by fishhead
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by fishhead
        
        
        
        Published on 2010-04-11T19:23:24Z
        Indexed on 
            2010/04/11
            20:03 UTC
        
        
        Read the original article
        Hit count: 268
        
sql-server
|sql
Below is my attempt at adding two values from separate select statements...it's not working, and I can't see why. I'm looking for some direction.
select (v1.Value + v2.Value) as total from
 ( 
     (Select   Max(Value) as [Value]  from History WHERE 
      Datetime>='Apr 11 2010  6:05AM' and Datetime<='Apr 11 2010  6:05PM' 
      and Tagname ='RWQ272017DTD'
     ) as v1
     (Select   Max(Value) as [Value]  from History WHERE 
      Datetime>='Apr 11 2010  6:05AM' and Datetime<='Apr 11 2010  6:05PM' 
      and Tagname ='RU282001DTD'
     ) as v2
)  
EDIT: Boy do I feel foolish...I asked the same question a few days ago...now I can't delete this.
© Stack Overflow or respective owner