From your question, apparently, you would like the last three cases to be conditions, or to link three different conditions together. Will the following example satisfy your question:
mytable: (unique keys 1..n) (col1) student-id | course-id | grade s1 gen101 g1 s1 cmp202 g2 s1 psy303 g3 s1 c4 g4 s2 c1 g5
Suppose we want students to have three special courses (gen101, cmp202, and psy303) and show that these classes ignore anyone else.
select gen.student-id as student-id , gen.grade as gen101-gr , cmp.grade as cmp202-gr , psy.grade as psy303-gr from mytable gen , mytable cmp , mytable psy where gen.course-id = 'gen101' and gen.student-id = cmp.student-id and cmp.course-id = 'cmp202' and cmp.studnet-id = psy.student-id and psy.course-id = 'psy303'
This should give one line:
student-id gen101-gr cmp202-gr psy303-gr s1 g1 g2 g3
Hope you have enough work.
source share