title: SQL rank percentile
body: <p>I've made an SQL query which rank pages by how many times they have been viewed.  For instance,</p>
  
  <pre><code>╔══════╦═══════╗
  ║ PAGE ║ VIEWS ║
  ╠══════╬═══════╣
  ║ J    ║   100 ║
  ║ Q    ║    77 ║
  ║ 3    ║    55 ║
  ║ A    ║    23 ║
  ║ 2    ║     6 ║
  ╚══════╩═══════╝
  </code></pre>
  
  <p>Now what I would like to do is find the percentile rank of each page using an SQL query.  The math I would like to use for this is simple enough, I just want to take the row number of the already generated table divided by the total number of rows.  Or 1 minus this value, depending on my interests.</p>
  
  <p>Can I do a COUNT(pages) on an already generated table like this?  I realize that's how I will get the total number of rows.  But are there any commands to return a row number?  </p>
  
  <p>Just to further clarify my question I need the following results</p>
  
  <pre><code>╔══════╦════════════════╗
  ║ PAGE ║ Percentile     ║
  ╠══════╬════════════════╣
  ║ J    ║   (1-1/5)*100  ║
  ║ Q    ║   (1-2/5)*100  ║
  ║ 3    ║   (1-3/5)*100  ║
  ║ A    ║   (1-4/5)*100  ║
  ║ 2    ║   (1-5/5)*100  ║
  ╚══════╩════════════════╝
  </code></pre>
  
  <p>Or in general (1-(row number)/(COUNT(page))*100</p>