title: PHP / SQL Group Rows and Sum Columns
body: <p>I have a database where I need to group users together and then sum the invoice amount into a total. I just cannot seem to figure an elegant way of doing this, I tried iterating though a while loop using each usersID via an IF statement but this method would not be practical as each new user added later would require a new if statement to be added.</p>
  
  <p>SQL Example</p>
  
  <pre><code>UserID  Invoice  InvoiceAMT
   419       1       20.00
   419       2       30.99
   420       3       30.00
   421       4        1.00
   419       5       60.00
  </code></pre>
  
  <p>What I want to return is</p>
  
  <pre><code>UserID   Total Invoices   Total Amount
   419           3            110.99
   420           1             30.00
   421           1              1.00
  </code></pre>