I have a table with 3 fields like this:
ProfessorID StudentID Mark P1 S1 9 P1 S2 8 P1 S3 10 P2 S1 7 P2 S2 2 P2 S3 4 P3 S4 5 P4 S1 6
A professor can teach many students, and vice versa, a student can learn from many professor. When a student learns from a professor, he gets his mark.
My problem is showing list of professors who teach at least 2 students, and 2 students who get best marks from those professors. In example, the query result of this table is:
ProfessorID StudentID Mark P1 S1 9 P1 S3 10 P2 S1 7 P2 S3 4
I've tried some solutions but they don't work right.
How can I do this correctly?