一个班级的学生有语文、数学、音乐等课程成绩,现求每位学生成绩最高的前两门课程;
如:
学生甲,语文:100,数学:90,音乐:80,则筛选出语文、数学;
学生乙,语文:80,数学:90,音乐:100,则筛选出数学、音乐;
尽量能用一条sql求出!
表:学生表student(id, name);
课程表course(id, name);
成绩表std_cor(id_student, id_course, score);
一个班级的学生有语文、数学、音乐等课程成绩,现求每位学生成绩最高的前两门课程;
如:
学生甲,语文:100,数学:90,音乐:80,则筛选出语文、数学;
学生乙,语文:80,数学:90,音乐:100,则筛选出数学、音乐;
尽量能用一条sql求出!
表:学生表student(id, name);
课程表course(id, name);
成绩表std_cor(id_student, id_course, score);
SELECT * FROM (select s.name "姓名", c.name "课程",sc.score "分数" from student s,course c,std_cor sc where s.id=sc.id_student and c.id=sc.id_course order by sc.score) where ROWNUM<=2 ORDER BY ROWNUM ASC