上面那条答案应该是可以的啊,可能是看起来复杂了点吧,我自己试过是没问题的:SELECT t1.sno,t1.cno,Score FROM SC t1 WHERE EXISTS (SELECT COUNT(1)FROM SC WHERE t1.cno= cno AND t1.score<score HAVING COUNT(1)<3)ORDER BY t1.cno,score DESC 另外还有一种类似的写法:SELECT t1.sno...
按照第一个条件 s1.course_id = s2.course_id把s1表的课程id和s2表的课程id对应起来,但是会产生多余的数据(会将不同sid,student_id,score,但是course_id相同的数据都连接一次),所以需要第二个条件进一步筛选我们的理想数据按照第二个条件s1.score >= s2.score将分数进行对比,然后进行连接,连接后的结果就是在...
select * from (select Student.S#,Sname,Sage,Ssex,SC.C#,score,Cname from SC inner join Student on SC.S#=Student.S inner join Course on Course.C#=SC.C#) as t where exists(select count(1) from t as d where C#=d.C# and score < d.score having count(1)<3 )请采纳答案...