title: SQL Server : summing two variables
body: <p>I am trying to add two variables </p>
  
  <pre><code>DECLARE @RentsSum MONEY
  SET @RentsSum = (SELECT SUM(Price)
                   FROM Rents
                   WHERE StartDate IS NOT NULL)
  GO
  
  DECLARE @SalesSum MONEY
  SET @PriceSum = (SELECT SUM(Price)
                   FROM Purchases
                   WHERE DateBought IS NOT NULL)
  GO
  
  DECLARE @SalesAndRentsSum MONEY
  
  SET @SalesAndRentsSum = @RentsSum + @PriceSum;
  
  SELECT @SalesAndRentsSum
  </code></pre>
  
  <p>into one but I get some strange errors here...</p>
  
  <blockquote>
    <p>Must declare the scalar variable "@PriceSum".</p>
    
    <p>Must declare the scalar variable "@RentsSum".</p>
  </blockquote>