title: Calculating range for a column based on its values
body: <p>I have some data like this.</p>
  
  <pre><code> Id  DaysPassed
   1   20
   2   40
   3   8
   4   64
  </code></pre>
  
  <p>Basically, Dayspassed could be any number. (Maybe I can say it is less than some X number, say 150). And as new data keeps coming in, DaysPassed could be different too.</p>
  
  <p>My requirement is to be able to define a range for these numbers. Like X rows are with 10-30 dayspassed range.</p>
  
  <p>I am not sure how to define this range in sql. I did some research and found something about moving range. Is it the same as what I am looking for? If not, how can I compute the range?</p>
  
  <p>I can do AVG() of all dayspassed and then get AVG() of that average, but I am not sure if this is right.</p>
  
  <p>I think the right way is to able to parse the data and be able to tell that these many rows are in X range. Any ideas?</p>
  
  <p>I am using sql server 2012.</p>