title: sql Alias Column Name for Use in CASE Statement
body: <p>I have an sql query as below,</p>
  
  <pre><code>select Site,DataSource,
  (SELECT CASE 
     WHEN DataSource = 'RFQ' THEN 'ChangeOperator' 
     ELSE 'SameOperator' 
    END) AS OperatorScenario,
  
    (SELECT CASE 
     WHEN OperatorScenario = 'ChangeOperator' THEN '1' 
     ELSE '022' 
    END) AS OperatorScenario2
  from tablename
  </code></pre>
  
  <p>when i execute this query i am getting exception as Invalid column name OperatorScenario. So i tried to use single codes in alias name in second query as below,</p>
  
  <pre><code>(SELECT CASE 
     WHEN 'OperatorScenario' = 'ChangeOperator' THEN '1' 
     ELSE '022' 
    END) AS OperatorScenario2
  </code></pre>
  
  <p>So then it executes always else part. Please give me some suggesssions.
  Regards
  sangeetha</p>