samedi 2 septembre 2017

Sorting student that are regular and irregular student

I Want to select the student that dont have a failing grade in its row.

 Stud_id   grade_1    grade_2    grade_3    RATE
  123        1.5       3.00        2.00    regular
  234        2.00      1.50        5.00    irregular   
  567        3.00      2.00        2.00    regular

select COUNT(stud_id) WHERE grade BETWEEN 1 AND 3 AND dont have grade IN(0,5).

my code for getting all the regular student is this.

 SELECT COUNT(DISTINCT stud_id FROM grade
 WHERE grade BETWEEN 1 AND 3 AND stud_id ='$student')

But my problem here is the student that have failed grade will also count since he also pass the other grade.

enter image description here

as you can see in the picture the student with ID ='67453432' should only be the student that will appear with "REGULAR" status because he doesnt have any failed grade. while the other student will appear as "IRREGULAR" since they have 1 or more failing grade.

the result should be like this

 EXAMPLE ONLY!!!
    if grade BETWEEN 1 AND 3 AND Dont have 0.00 OR 5.00 = REGULAR
     BUT if GRADE BETWEEN 1 AND 3 AND HAVE 0.0 OR 5.00 = IRREGULAR

    Stud_ID   RATE
    67453432 REGULAR
     123     REGULAR
     234     IRREGULAR
     567     REGULAR

Aucun commentaire:

Enregistrer un commentaire