title: Calculating percentages with GROUP BY query
body: <p>I have a table with 3 columns which looks like this:</p>
  
  <pre><code>File    User     Rating (1-5)
  ------------------------------
  00001    1        3
  00002    1        4
  00003    2        2
  00004    3        5
  00005    4        3
  00005    3        2
  00006    2        3
  Etc.
  </code></pre>
  
  <p>I want to generate a query that outputs the following (for each user and rating, display the number of files as well as percentage of files):</p>
  
  <pre><code>User    Rating   Count   Percentage
  -----------------------------------
  1       1         3      .18
  1       2         6      .35
  1       3         8      .47
  2       5         12     .75
  2       3         4      .25
  </code></pre>
  
  <p>With Postgresql, I know how to create a query that includes the first 3 columns using the following query, but I can't figure out how to calculate percentage within the GROUP BY:</p>
  
  <pre><code>SELECT
      User,
      Rating,
      Count(*)
  FROM
      Results
  GROUP BY
      User, Rating
  ORDER BY
      User, Rating
  </code></pre>
  
  <p>Here I want the percentage calculation to apply to each user/rating group.</p>