title: Using case statement to do binning in sql
body: <p>We have a small table in following structure;</p>
  <pre><code>act_id | ratio
   123   |  0
   234   |  0.001
   235   |  0.05  
  </code></pre>
  <p>I am trying to use <code>CASE</code> statement to add anew column which does bucketing sth like;</p>
  <pre><code>SELECT act_id,
         ratio,
         CASE WHEN 0 &lt;ratio &lt;= 0.04 THEN '(0,0.04]'
              WHEN ratio &gt; 0.04  THEN ratio END AS new_col
  FROM table
  </code></pre>
  <p>But it gives the following error; <code>SQL compilation error: error line 50 at position 56 invalid identifier '&quot;(0,0.04]&quot;'</code>. The desired output is</p>
  <pre><code>act_id | ratio | new_col
   123   |  0.   |. 0
   234   |  0.001| (0,0.04]
   235   |  0.05 | 0.05
  </code></pre>
  <p>may I know how can we use the CASE statement here to put desired strings in this new_col, using open or closed intervals. Helps appreciated.</p>