title: How to get average rating of 5 for each post on a single query
body: <p>I have a table that stored post's feedback comment and rating given by their customers. I just want to know how to query the average rating for each post divided by 5 in percentage.</p>
  <p>So the formula will be like this. For example :</p>
  <pre><code> (rate1 * customer) + (rate2 * customer)
  ----------------------------------------- * 100 / 5 = AVERAGE percentage within 5 stars rating
         total customer(per post)
  </code></pre>
  <p>So my query for now is like this :</p>
  <pre><code>SELECT 
      service_providers_post,
      rating,
      count(customer) as 'perrate_customers',
      t.perpost_customers
  FROM serviceproviders_feedback
  JOIN (SELECT 
          service_providers_post as 'postid',
          COUNT(customer) as 'perpost_customers'
      FROM serviceproviders_feedback
      GROUP BY service_providers_post) t
  on t.postid = serviceproviders_feedback.service_providers_post
  GROUP BY service_providers_post, rating
  </code></pre>
  <p>The output for the above query is like this :</p>
  <p><a href="https://i.stack.imgur.com/jAcTJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jAcTJ.jpg" alt="View query per rating" /></a></p>
  <p>The output that I want is to display average rating of each rate between 1 - 5 for each post.</p>
  <p>So how to get the average for each post in a query?</p>
  <p>Here a link as an example of my table</p>
  <p><a href="http://sqlfiddle.com/#!9/234dd9/6" rel="nofollow noreferrer">SqlFiddle</a></p>