title: SQL to SUM certain rows only
body: <p>I'm trying to find a method to sum a dollar amount in a small data set, but only on certain rows. This data is extracted from another system that I cannot change. This will be used for one-time data import into SQL so pretty and efficient are low priority. I need to sum the rows where a specific person ID has made two or more payments for the same event code. </p>
  
  <p>In the data, all columns (many not shown) for the person paying are the same except for  AmountPaid and DatePaid. I want to SUM AmountPaid (and get MAX of DatePaid if possible).</p>
  
  <p>Data looks like this:</p>
  
  <pre><code>EventCode | PersonID | DatePaid | AmountPaid
  ****    
  EventA | Person123 |2017-01-01 | $50
  EventA | Person456 |2017-02-01 | $100
  EventA | Person123 |2017-02-02 | $50
  EventB | Person123 |2016-01-01 | $100
  EventC | Person456 |2017-07-07 | $200
  EventC | Person123 |2017-08-08 | $200
  </code></pre>
  
  <p>What I need to do is total just the payments for EventA made by Person123 - total should $100 (50+50), so I can import this as one payment transaction.</p>
  
  <p>Ideal results would like this:</p>
  
  <pre><code>EventCode | PersonID | DatePaid | AmountPaid
  ****    
  EventA | Person456 |2017-02-01 | $100
  EventA | Person123 |2017-02-02 | $100
  EventB | Person123 |2016-01-01 | $100
  EventC | Person456 |2017-07-07 | $200
  EventC | Person123 |2017-08-08 | $200
  </code></pre>
  
  <p>Thanks,</p>