title: T-SQL creating variables within a larger SELECT statement? Is there a quicker way?
body: <p>Let's say I have the world's 2 simplest tables as my data:</p>
  
  <p>The first table looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/3zWHI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3zWHI.png" alt="enter image description here"></a></p>
  
  <p>The second table looks like this: </p>
  
  <p><a href="https://i.stack.imgur.com/oBlxp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oBlxp.png" alt="enter image description here"></a></p>
  
  <p>Then let's say I have the following statement in T-SQL</p>
  
  <pre><code>SELECT  
      T1.Column1 + T2.Column1 AS 'AddedColumns'
  FROM 
      Table1 AS T1, Table2 AS T2 
  </code></pre>
  
  <p>So my result should display a single column with values : 6 and 9 that I have aliased as "AddedColumns"</p>
  
  <p>Let's say for the sake of argument I wanted to add Column 2 from Table 1 to "Added Columns" how would I do that? </p>
  
  <p>One way I understand is to declare variables at the top, but that would require reproducing the SELECT, FROM and crucially the WHERE statements that I tag on. Is there a way to just do something like:</p>
  
  <pre><code>SELECT  
      T1.Column1 + T2.Column AS 'AddedColumns',
      'AddedColumns' + T2.Column2 AS 'Double Added'
  FROM 
      Table1 AS T1, Table2 AS T2 
  </code></pre>
  
  <p>Or do I just have to do something like:</p>
  
  <pre><code>Declare @NewVariable Int = SELECT (..... FROM ....... WHERE......)
  </code></pre>
  
  <p>At the very top for every variable I wish to store?</p>