title: TSQL - Use a Derived Select Column in the Where Clause
body: <p>Is there a way in TSQL to do something like this:</p>
  
  <pre><code>select a,b,c,
  case 
    when a=1 then 5
    when a=2 then 6
  end as d
  from some_table
  where d=6
  </code></pre>
  
  <p>The actual case statement is really complex, so I'm trying to avoid repeating it in the where clause?  Are there any tricks to do this?</p>
  
  <p>(I think there's a trick in MySQL to use "having d=6").</p>