title: SQL Show most recent record in GROUP BY?
body: <p>I have a table that looks like this:</p>
  
  <pre><code>id    |    SubjectCode    |    Grade    |    DateApproved    |    StudentId
  
  1            SUB123            1.25            1/4/2012            2012-12345
  
  2            SUB123            2.00            1/5/2012            2012-12345
  
  3            SUB123            3.00            1/5/2012            2012-98765   
  </code></pre>
  
  <p>I'm trying to GROUP BY SubjectCode but i'd like it to display the most recent DateApproved so it will look like:</p>
  
  <pre><code>  id    |    SubjectCode    |    Grade    |    DateApproved    |    StudentId
  
  2            SUB123            2.00            1/5/2012            2012-12345
  
  3            SUB123            3.00            1/5/2012            2012-98765  
  </code></pre>
  
  <p>I'm a little bit lost on how to do it?</p>
  
  <p>EDIT:</p>
  
  <p>Ok guys now im on my real PC, sorry for the poorly constructed question. </p>
  
  <p>Here's what I'm actually trying to do:</p>
  
  <pre><code>SELECT GD.GradebookDetailId, G.SubjectCode, G.Description, G.UnitsAcademic, G.UnitsNonAcademic, 
  GD.Grade, GD.Remarks, G.FacultyName, STR_TO_DATE(G.DateApproved, '%m/%d/%Y %h:%i:%s') AS 'DateAproved'
  FROM gradebookdetail GD INNER JOIN gradebook G ON GD.GradebookId=G.GradebookId 
  WHERE G.DateApproved IS NOT NULL AND G.GradebookType='final' AND StudentIdNumber='2012-12345'
  
  GROUP BY &lt;?????&gt;
  ORDER BY G.SubjectCode ASC
  </code></pre>
  
  <p>Basically, I only want to display the <strong>most recent</strong> "DateApprove" of a "SubjectCode", so I don't get multiple entries.</p>