title: Filter Students by their highest marks
body: <p>I have a mysql table</p>
  
  <p>table name 'results'</p>
  
  <pre><code>Reg.No  SubjectCode  Attempt  Grade  Marks
  112108  CMIS 1113    1        D      17
  112110  CMIS 1114    1        A      85
  112119  CMIS 1114    1        D      18
  112108  CMIS 1113    2        D+     25
  112110  CMIS 1113    1        D+     25
  112107  CMIS 1113    1        B      70
  112108  CMIS 1113    3        C      40
  112110  CMIS 1113    2        C      40
  112119  CMIS 1114    2        C      42
  112120  CMIS 1114    1        D      17
  </code></pre>
  
  <p>This is about students' results.<br> Students need at least a "C"
      (marks>40) to pass the subject.<br> Until pass, students can have
      several attempts.<br> But from the second attempt maximum grade they
      can get is "C"<br> So students who was unable to pass the subject in
      first attempt,used to have another try until they pass the subjects
      <br>So for final results sheet the highest result will be take into account in each subjects.(highest results is given by the highest marks)<br>
  So for example highest marks of 112108 for CMIS 1113 is 40.<br>
  So likewise I want to get the students results for ecch subjects(But always maximum marks will be take into account)<br>
  Actually my expected results table should be like this<br></p>
  
  <pre><code>Reg.No  SubjectCode  Attempt  Grade  Marks
  112110  CMIS 1114    1        A      85
  112107  CMIS 1113    1        B      70
  112108  CMIS 1113    3        C      40
  112110  CMIS 1113    2        C      40
  112119  CMIS 1114    2        C      42
  112120  CMIS 1114    1        D      17
  </code></pre>
  
  <p>So how can I retrieve these data using sql query? </p>