title: SQL: find percentiles
body: <p>I have a table that has a certain numeric column called <code>Score</code>. I would like to execute a query on that table, whose result will have 100 rows, each representing the score corresponding with that percentile. For example, a result may look as follows:</p>
  
  <pre><code> Percentile | Score
  ---------------------
   01         | 10
   02         | 12
   03         | 12
   04         | 17
   ...        | ...
   99         | 1684
   100        | 1685
  </code></pre>
  
  <p>The Score values in the result table above are actual score values that exist in the original table, and are not interpolated. An interpolated result will be better but is not a requirement.</p>
  
  <p>There may be several heuristics that can produce such a result. What I'm using today (in code) is basically as follows - The Score value corresponding with a percentile will be the score value for which: the number of rows with smaller scores, divided by the total number of rows, rounded to an integer, equals to the percentile (I hope that's clear)</p>
  
  <p>I can consider other heuristics if they are easier to implement</p>
  
  <p>I'm working in MS-SQL, but would appreciate a solution that also works on MySQL.</p>
  
  <p>What's the best way to achieve this?</p>