samedi 27 décembre 2014

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?





Aucun commentaire:

Enregistrer un commentaire