title: How to use calculated column value to another column in the same SQL Query
body: <p>I am writing a query, which is using SubQuery to get some result. </p>
  
  <p>Instead of rewriting the SubQuery every time, i want to use the same output value of column 1 as input to another column for the further calculation.</p>
  
  <p>Point 1: Can we use any variable to save the value into it and use the same for another column.</p>
  
  <p>Sample expected code:</p>
  
  <pre><code>  SELECT COLUMN1
          ,CASE WHEN (SELECT CancelDate FROM TABLE3 WHERE EXPR....) &lt;&gt; '' THEN 'Cancel' ELSE 'New' END AS **TransactionType**
          ,COLUMN2
          ,CASE **TransactionType** WHEN 'Cancel' THEN EXPR 1.... 
           CASE **TransactionType** WHEN 'New' THEN EXPR 2 .... END AS CALCOLUMN2     
  FROM TABLE1
  JOIN TABLE2 ....
  </code></pre>