title: Mysql query sum another column with a condition
body: <p>this is my first question so I hope that I don't mess it up.</p>
  
  <p>Here's a SQL Fiddle I made to help me explain it: <a href="http://sqlfiddle.com/#!9/7f2b5c/7" rel="nofollow noreferrer">http://sqlfiddle.com/#!9/7f2b5c/7</a></p>
  
  <p>We have questions, answers, question_types and answer_types.</p>
  
  <p>I want to know for each question, how many people have answered each answer_type and how many people have answered that question, but I'm unable to get the total.</p>
  
  <p>This is what I'm getting:</p>
  
  <pre><code>id | fk_question_type | description            | num | value      | total
  1  | 1                | How was the breakfast? | 0   | Bad        | 0
  1  | 1                | How was the breakfast? | 1   | Good       | 1
  1  | 1                | How was the breakfast? | 0   | Indifferent| 0
  1  | 1                | How was the breakfast? | 2   | Very good  | 2
  2  | 1                | How was the lunch?     | 0   | Bad        | 0
  2  | 1                | How was the lunch?     | 1   | Good       | 1
  2  | 1                | How was the lunch?     | 0   | Indifferent| 1
  2  | 1                | How was the lunch?     | 1   | Very good  | 1
  </code></pre>
  
  <p>This is what I'd like:</p>
  
  <pre><code>id | fk_question_type | description            | num | value      | total
  1  | 1                | How was the breakfast? | 0   | Bad        | 3
  1  | 1                | How was the breakfast? | 1   | Good       | 3
  1  | 1                | How was the breakfast? | 0   | Indifferent| 3
  1  | 1                | How was the breakfast? | 2   | Very good  | 3
  2  | 1                | How was the lunch?     | 0   | Bad        | 2
  2  | 1                | How was the lunch?     | 1   | Good       | 2
  2  | 1                | How was the lunch?     | 0   | Indifferent| 2
  2  | 1                | How was the lunch?     | 1   | Very good  | 2
  </code></pre>
  
  <p>The query I'm trying right now:</p>
  
  <pre><code>SELECT id, fk_question_type, description, num, value, SUM(num) AS totalAnswers
  FROM (
      (SELECT q.id, q.fk_question_type, q.description, COUNT(a.id) AS num, at.value
      FROM answer a 
      LEFT JOIN question q ON a.`fk_question`=q.`id` 
      LEFT JOIN answer_type at ON at.id = a.`fk_answer_type` 
      GROUP BY q.id, at.id  ORDER BY q.id, at.id)
      UNION ALL
      (SELECT q.id, q.fk_question_type, q.description, 0 AS num, at.value
      FROM answer a 
      LEFT JOIN question q ON a.`fk_question`=q.`id` 
      LEFT JOIN answer_type at ON at.fk_question_type=q.fk_question_type
      GROUP BY q.id, at.id  ORDER BY q.id, at.id)
  ) AS T 
  WHERE fk_question_type = 1
  GROUP BY id, value ORDER BY id
  </code></pre>
  
  <p>How can I SUM the num for the rows with the same id while keeping the other columns?</p>