mysql> select sname from student,sc where student.sno=sc.sno and sc.sno not in?(select r.sno from (select sno,score from sc,course where sc.cno=course.cno and course.cname='數(shù)據(jù)庫(kù)') AS r INNER JOIN(select sno,avg(score) avg_grade FROM sc group by sno) AS t ON r.sno=t.sno and r.score<t.avg_grade);
3 回答
已采納

一瞬兒光
TA貢獻(xiàn)178條經(jīng)驗(yàn) 獲得超70個(gè)贊
SELECT?sname?FROM?student?WHERE?sno?in(SELECT?sno?FROM?sc?WHERE?score?>=?(SELECT?avg(`score`)?FROM?sc?GROUP?BY?(SELECT?cno?FROM?course?WHERE?cname='數(shù)據(jù)庫(kù)')));

一瞬兒光
TA貢獻(xiàn)178條經(jīng)驗(yàn) 獲得超70個(gè)贊
SELECT?sname?from?student?WHERE?sno?in(select?temp.sno?FROM?(select?sno,avg(score)?as?avgs?FROM?sc?GROUP?BY?sno)?as?temp?where?temp.sno?in(SELECT?sc.sno?from?sc?where?sc.sno=temp.sno?and?sc.cno=(SELECT?course.cno?from?course?WHERE?cname='數(shù)據(jù)庫(kù)')?and?sc.score>=temp.avgs));
你的表述就有問(wèn)題,還0分,無(wú)語(yǔ)?。。∵@會(huì)再試試吧

俠客島的含笑
TA貢獻(xiàn)552條經(jīng)驗(yàn) 獲得超285個(gè)贊
SELECT sname FROM student WHERE sno in(SELECT sno FROM sc WHERE cno=(SELECT cno FROM course WHERE cname='數(shù)據(jù)庫(kù)') and score>=(SELECT avg(`score`) FROM sc group BY sno));
添加回答
舉報(bào)
0/150
提交
取消