title: Complex SQL query with group by and two rows in one
body: <p>Okay, I need help. I'm usually pretty good at SQL queries but this one baffles me. By the way, this is not a homework assignment, it's a real situation in an Access database and I've written the requirements below myself.</p>
  
  <hr>
  
  <p>Here is my table layout. It's in Access 2007 if that matters; I'm writing the query using SQL.</p>
  
  <pre><code>Id (primary key)
  PersonID (foreign key)
  EventDate
  NumberOfCredits
  SuperCredits (boolean)
  </code></pre>
  
  <p>There are events that people go to. They can earn normal credits, or super credits, or both at one event. The SuperCredits column is true if the row represents a number of super credits earned at the event, or false if it represents normal credits.</p>
  
  <p>So for example, if there is an event which person 174 attends, and they earn 3 normal credits and 1 super credit at the event, the following two rows would be added to the table:</p>
  
  <pre><code>ID PersonID EventDate NumberOfCredits SuperCredits
  1  174      1/1/2010  3               false
  2  174      1/1/2010  1               true
  </code></pre>
  
  <p>It is also possible that the person could have done two separate things at the event, so there might be more than two columns for one event, and it might look like this:</p>
  
  <pre><code>ID PersonID EventDate NumberOfCredits SuperCredits
  1  174      1/1/2010  1               false
  2  174      1/1/2010  2               false
  3  174      1/1/2010  1               true
  </code></pre>
  
  <p>Now we want to print out a report. Here will be the columns of the report:</p>
  
  <pre><code>PersonID
  LastEventDate
  NumberOfNormalCredits
  NumberOfSuperCredits
  </code></pre>
  
  <p>The report will have one row per person. The row will show the latest event that the person attended, and the normal and super credits that the person earned at that event.</p>
  
  <p><strong>What I am asking of you is to write, or help me write, the SQL query to SELECT the data and GROUP BY and SUM() and whatnot.</strong> Or, let me know if this is for some reason not possible, and how to organize my data to make it possible.</p>
  
  <hr>
  
  <p>This is extremely confusing and I understand if you do not take the time to puzzle through it. I've tried to simplify it as much as possible, but definitely ask any questions if you give it a shot and need clarification. I'll be trying to figure it out but I'm having a real hard time with it, this is grouping beyond my experience...</p>