select class.classid,avg(choice.score)as avgscore
from choice,student,class
where choice.sid=student.sid and student.classid=class.classid
and class.grade='a'
group by class.classid
from choice,student,class
where choice.sid=student.sid and student.classid=class.classid
and class.grade='a'
group by class.classid
from choice a ,student b ,class c
where a.sid=b.sid and b.classid=c.classid
and c.grade='a'
group by c.classid
from choice h innser join student s on h.stid=s.sid
inner join class c on s.classid=c.classid and c.grade='a'
group by c.classid
cl.classid,avg(ch.score)as avgscore
from
choice ch,class cl
where
ch.sid in(select sid from student st where st.classid=cl.classid)
and
cl.grade='a'
group by
cl.classid
select class.classid,avg(choice.score)as avgscore
from choice,student,class
where choice.sid=student.sid and student.classid=class.classid
and class.grade in (select distinct grade from class)
group by class.classid
select avg(score)
from choice
where sid in
(select sid
from student
where classid in
(select classid
from class
where grade='a'
group by classid)
)
select classid, avg(score) as avgscore
from choice
where sid in
(
select distinct sid from student where classid in
(
select distinct classid from class where grade='a'
)
)
group by classid
from choice,student,class
where choice.sid=student.sid and student.classid=class.classid
and class.grade='a'
group by class.classid
----------------------------------
楼主,最外层用了group by class.classid,而你的avg(choice.score)要从choice取数据,就注定了class、choice必须放在同一级处理,不应该用你所说的“要纯in()的那种”。不太明白楼主为什么一定要这种
字段,倒是可以