title: Use comparison signs inside a sql case statement
body: <p>I'm looking for a way to build case statements in a sql select query using less than and greater than signs. For example, I want to select a ranking based on a variable:</p>
  
  <pre><code>DECLARE @a INT
  SET @a = 0
  
  SELECT CASE 
           WHEN @a &lt; 3 THEN 0
           WHEN @a = 3 THEN 1
           WHEN @a &gt; 3 THEN 2
         END
  </code></pre>
  
  <p>I'd like to write it as:</p>
  
  <pre><code>DECLARE @a INT
  SET @a = 0
  
  SELECT CASE @a
           WHEN &lt; 3 THEN 0
           WHEN 3 THEN 1
           WHEN &gt; 3 THEN 2
         END
  </code></pre>
  
  <p>...but SQL doesn't let me use the &lt; and > signs in this way. Is there a way that I can do this is SQL 2005, or do I need to use the code like in the first one.</p>
  
  <p>The reason for only wanting the code there once is because it would make the code a lot more readable/maintainable and also because I'm not sure if SQL server will have to run the calculation for each CASE statement.</p>
  
  <p>I'm looking for a VB.NET case statement equivelent:</p>
  
  <pre><code>Select Case i
      Case Is &lt; 100
          p = 1
      Case Is &gt;= 100
          p = 2
  End Select
  </code></pre>
  
  <p>Maybe it's not possible in SQL and that's ok, I just want to confirm that.</p>