title: Creating Range Buckets of column
body: <p>I am having one base table named test_table on which I am doing calculation of the age and it is coming as per expectation.</p>
  
  <p>Here is the query I am using for age calculation.</p>
  
  <pre><code>select acol,
         DATEDIFF(hour,CONVERT(DATEADD('SECOND', (epoch_time)/1000, DATE '1970-01-01'), DATE), CURRENT_TIMESTAMP()) AS age
  from test_table;
  </code></pre>
  
  <p>But now I want to create different range of age column which will be displayed as a result by modifying the existing query.</p>
  
  <p>Range would be :</p>
  
  <pre><code>1000-2000
  
  2000-3000
  
  3000-4000
  
  ACOL       AGE  
  MAG        1168
  MAG        2168
  MAG        3168
  MAG        1100
  MAG        2168
  PNB        1672
  MUM        1600
  MUM        2696
  MUM        3696
  MUM        1696
  </code></pre>
  
  <p>Result after successful query has to look like below table.</p>
  
  <pre><code>ACOL 1000-2000  2000-3000 3000-4000
  MAG      2          2          1
  PNB      1          0          0
  MUM      2          1          1
  </code></pre>
  
  <p>I know that we can do this using select case but not able to build the working query.
  can anyone help me in this.</p>
  
  <p>thanks in advance.</p>