title: Use "result expression" from CASE expression in WHERE clause
body: <p>Is it possible to filter records in SQL Server by using a result expression (weight_class) from a <code>CASE</code> expression in the <code>WHERE</code> clause? I can't get it to work because I get an error saying: </p>
  
  <blockquote>
    <p>Invalid column name 'weight_class'</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>SELECT 
      first_name, last_name, 
      weight_class = CASE
                        WHEN weight &lt; 172 THEN 'Welterweight'
                        WHEN weight &lt;= 192 THEN 'Middleweight'
                        WHEN weight &lt;= 214 THEN 'Light heavyweight'
                        WHEN weight &lt;= 220 THEN 'Cruiserweight'
                        ELSE 'Heavyweight'
                     END
  FROM 
      athletes
  </code></pre>
  
  <p>This is how I want to do:</p>
  
  <pre><code>SELECT 
      first_name, last_name, 
      weight_class = CASE
                        WHEN weight &lt; 172 THEN 'Welterweight'
                        WHEN weight &lt;= 192 THEN 'Middleweight'
                        WHEN weight &lt;= 214 THEN 'Light heavyweight'
                        WHEN weight &lt;= 220 THEN 'Cruiserweight'
                        ELSE 'Heavyweight'
                     END
  FROM 
      athletes
  WHERE 
      weight_class = 'Cruiserweight'
  </code></pre>