title: CTE inside SQL IF-ELSE structure
body: <p>I want to do something like this</p>
  
  <pre><code>declare @a int=1
  if (@a=1)
  with cte as 
  (
  select UserEmail from UserTable 
  )
  else
  with cte as
  (
  select UserID from UserTable
  )
  select * from cte
  </code></pre>
  
  <p>This is just the example, my actual query is far more complex. So I don't want to write the <code>SELECT</code> statement inside <code>IF</code> and <code>ELSE</code> statement twice after the CTE.</p>