title: SQL 'CASE WHEN x' vs. 'CASE x WHEN' with greater-than condition?
body: <p>This is a questions about the two ways to use the SELECT CASE in MS SQL [CASE WHEN X = Y] and [CASE X WHEN Y]</p>
  
  <p>I am trying to define buckets for a field based on its values. I would need to use ranges, so it is necessary to use the "&lt;" or ">" identifiers.</p>
  
  <p>As a simple example, I know it works like this:</p>
  
  <pre><code>SELECT CASE WHEN x &lt; 0 THEN 'a' WHEN X &gt; 100 THEN 'b' ELSE 'c' END
  </code></pre>
  
  <p>Now I have to write a lot of these, there will be more than 3 buckets and the field names are quite long, so this becomes very difficult to keep clean and easy to follow. I was hoping to use the other way of the select command but to me it looks like I can only use it with equals:</p>
  
  <pre><code>SELECT CASE X WHEN 0 then 'y' ELSE 'z' END
  </code></pre>
  
  <p>But how can I use this form to specify range conditions just as above? Something like:</p>
  
  <pre><code>SELECT CASE X WHEN &lt; 0 THEN 'a' WHEN &gt; 100 THEN 'b' ELSE "c" END
  </code></pre>
  
  <p>This one does not work.</p>
  
  <p>Thank You!</p>