How to filter maximum results entries I have a mysql table

table name 'results'

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


This is about students' results. Students need at least a "C"
    (marks>40) to pass the subject. Until pass, students can have
    several attempts. But from the second attempt maximum grade they
    can get is "C" So students who was unable to pass the subject in
    first attempt,used to have another try until they pass the subjects
    So for final results sheet the highest result will be take into account in each subjects.(highest results is given by the highest marks)
So for example highest marks of 112108 for CMIS 1113 is 40.
So likewise I want to get the students results for ecch subjects(But always maximum marks will be take into account)
Actually my expected results table should be like this

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


So how can I retrieve these data using sql query?
This is a way of doing it. Can be tested in http://sqlfiddle.com/#!2/7c4525/4

SELECT R1.*
FROM Results R1
INNER JOIN
(
  SELECT RegNo, SubjectCode, Max(Marks) AS MaxMark
  FROM Results
  GROUP BY RegNo, SubjectCode
) R2
ON R1.RegNo = R2.RegNo 
  AND R1.SubjectCode = R2.SubjectCode 
  AND R1.Marks = R2.MaxMark


This previous solution could output several rows for the same Reg.No and SubjectCode in case that student tied for her best result in more than one attempt.
In this case, if only the row from the last attempt is wanted to be shown you can use the following variation. 
Can be tested in http://sqlfiddle.com/#!2/070c5/3. Note that I have added an extra row to the sample data you provided in order to reproduce the situation.

SELECT R1.RegNo, R1.SubjectCode, Max(R1.Attempt), R1.Grade, R1.Marks
FROM Results R1
INNER JOIN
(
  SELECT RegNo, SubjectCode, Max(Marks) AS MaxMark
  FROM Results
  GROUP BY RegNo, SubjectCode
) R2
ON R1.RegNo = R2.RegNo 
  AND R1.SubjectCode = R2.SubjectCode 
  AND R1.Marks = R2.MaxMark
GROUP BY RegNo, SubjectCode, Grade, Marks


However, if in case of ties, the prefered result to be shown is the lower attempt number Max(R1.Attempt) should be replaced by Min(R1.Attempt)