title: GROUP_CONCAT + SUM / COUNT in mysql not working
body: <p>I have some tables liek this</p>
  
  <pre><code>User         : id , username
  answers      : id , answers , is_correct , question_id
  user_answers : user_id , question_id , answer_id , date
  questions    : id , question , category
  category     : id name
  </code></pre>
  
  <p>Now what i am trying to do is count the correct answers user have given on each category. My query is this</p>
  
  <pre><code>SELECT
    u.`user_name` AS `UserName`,
    u.`user_id`   AS `UserId`,
    sum(a.is_correct) AS `Score`,
    group_concat(distinct c.name) AS `Quizes`
  FROM users_answers ua
    LEFT JOIN answers a
      on a.id = ua.answer_id
    LEFT JOIN users u
      ON u.user_id = ua.user_id
    left join questions q
      on q.id = a.question_id
    left join categories c
      on c.id = q.cat_id
  WHERE a.is_correct = 1
  GROUP BY u.user_id
  ORDER BY `Score` desc, ua.date desc;
  </code></pre>
  
  <p>It brings the result ok but i need to get the total score seperatly for each category.</p>
  
  <p>EDITS</p>
  
  <pre><code>select
    s.UserName,
    s.UserId,
    GROUP_CONCAT(Score) AS CategoryScores,
    sum(s.TotalScore) as TotalScore,
    s.Quizes,
    s.LastPlayed
  from (select
          u.`user_name` AS `UserName`,
          u.`user_id`   AS `UserId`,
          sum(a.is_correct) AS `Score`,
          sum(a.is_correct) AS `TotalScore`,
          group_concat(distinct c.name) AS `Quizes`,
          ua.date       as `LastPlayed`,
          c.id          as CategoryId
        FROM users_answers ua
          LEFT JOIN answers a
            on a.id = ua.answer_id
          LEFT JOIN users u
            ON u.user_id = ua.user_id
          left join questions q
            on q.id = a.question_id
          left join categories c
            on c.id = q.cat_id
        WHERE a.is_correct = 1
        GROUP BY u.user_id, CategoryId) s
  GROUP BY UserId
  ORDER BY `TotalScore` desc, LastPlayed desc;
  </code></pre>
  
  <p>Thanks Michael but the problem here is that now i cant get categories names in group concat.</p>