title: Sum query not working properly properly sql and php
body: <p>Why this query instead of displaying the sum of points for each user, it display the sum of all together</p>
  
  <p>I have written an <code>SQL</code> query that displays the sum of all point for all users, whereas I would like it to: <em>display the sum of points for each user.</em></p>
  
  <p>The table that I have written contains the following:</p>
  
  <pre><code>id  |  Score
  1   |   20
  2   |   30
  2   |   50
  1   |   10
  </code></pre>
  
  <p>Total table :</p>
  
  <pre><code>id | points
  
  1  | 30
  
  1  | 40
  </code></pre>
  
  <p>What I want is to add the score for <code>user(1) = 30</code> and <code>user(2) = 80</code></p>
  
  <pre><code>Id: 1 = 30 = Fail
  Id: 2 = 80 = Pass
  </code></pre>
  
  <p>The query I have written :</p>
  
  <pre><code>$query = "SELECT SUM(sg.score) as sum, SUM(a.total) as suma FROM points as sg, totalpoints as a
            WHERE a.id = 1 GROUP BY sg.id";
  </code></pre>
  
  <p>And related <code>PHP</code> code is as follows:</p>
  
  <pre><code>&lt;?php
    foreach($rowsum as $rowsm): 
      if( ' '. htmlentities($rowsm['sum']) . '' &gt; 50  )
        echo 'Pass';
      else if( ' '. htmlentities($rowsm['sum']) . '' &gt;= 40  )
        echo 'Failed';
  
      echo ' ' . htmlentities($rowsm['sum'], ENT_QUOTES, 'UTF-8') . '&lt;br&gt;';
  
    endforeach;
  ?&gt;
  </code></pre>