本文发表在 rolia.net 枫下论坛I do not know if I understand your question clearly, but I can give you one example how to deal with this kind of problem.
Table A,
Student No, Course No, Score
1111, A11 80
2222, A11 85
3333, A11 70
1111, A12 50
2222 A12 60
3333 A12 40
2222 A13 50
3333 A13 90
You want to turn into the format like this
Student NO, Score of CourseA1, Score of CourseA2, Score of CourseA3
1111 80 50
2222 85 60 50
3333 70 40 90
Here you know the course will only be A1,A2,A3, this is the key point here.
select aliasppp.studentNO,
( select aliasp.score
from A aliasp
where aliasp.studentNO = aliasppp.studentNO
and aliasp.course = 'A1) ,
( select aliasp.score
from A aliasp
where aliasp.studentNO = aliasppp.studentNO
and aliasp.course = 'A2) ,
( select aliasp.score
from A aliasp
where aliasp.studentNO = aliasppp.studentNO
and aliasp.course = 'A3)
FROM A aliasppp更多精彩文章及讨论,请光临枫下论坛 rolia.net
Table A,
Student No, Course No, Score
1111, A11 80
2222, A11 85
3333, A11 70
1111, A12 50
2222 A12 60
3333 A12 40
2222 A13 50
3333 A13 90
You want to turn into the format like this
Student NO, Score of CourseA1, Score of CourseA2, Score of CourseA3
1111 80 50
2222 85 60 50
3333 70 40 90
Here you know the course will only be A1,A2,A3, this is the key point here.
select aliasppp.studentNO,
( select aliasp.score
from A aliasp
where aliasp.studentNO = aliasppp.studentNO
and aliasp.course = 'A1) ,
( select aliasp.score
from A aliasp
where aliasp.studentNO = aliasppp.studentNO
and aliasp.course = 'A2) ,
( select aliasp.score
from A aliasp
where aliasp.studentNO = aliasppp.studentNO
and aliasp.course = 'A3)
FROM A aliasppp更多精彩文章及讨论,请光临枫下论坛 rolia.net