title: Group survey rating data in mysql
body: <p>I just want to ask if there is another way to achieve this kind of result in mysql (
  <a href="https://i.stack.imgur.com/kFtQA.png" rel="nofollow noreferrer">image sample of what i want to achieve</a> ).</p>
  <p>So far, this is what i have done to do it. <a href="https://i.stack.imgur.com/N848H.jpg" rel="nofollow noreferrer">Sample Result</a></p>
  <pre><code>SELECT CONCAT('tbl1_row1'), a.excellent, b.moderate, c.fair, d.didnot FROM (select count(id) as excellent from part2_a2 where tbl1_row1 = 4) a, (select count(id) as moderate from part2_a2 where tbl1_row1 = 3) b, (select count(id) as fair from part2_a2 where tbl1_row1 = 2) c, (select count(id) as didnot from part2_a2 where tbl1_row1 = 1) d
      
      UNION SELECT CONCAT('tbl1_row2'), a.excellent, b.moderate, c.fair, d.didnot FROM (select count(id) as excellent from part2_a2 where tbl1_row2 = 4) a, (select count(id) as moderate from part2_a2 where tbl1_row2 = 3) b, (select count(id) as fair from part2_a2 where tbl1_row2 = 2) c, (select count(id) as didnot from part2_a2 where tbl1_row2 = 1) d
  </code></pre>
  <p>What im doing is counting the rating responses from individuals and grouping them based on their ratings. Im thinking that this is not the best way to do it since if i have like 50 questions that i will have to create 50 union statements in my sql which i think will have an impact in permormance. <a href="https://i.stack.imgur.com/OWczk.jpg" rel="nofollow noreferrer">Here is a sample image of my table.</a>
  any advice would be helpful. thanks!</p>