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

解决方案 »

  1.   

    请帮忙转换成那种内联接的,就是带where in(select)等等,上面已经给出代码,帮忙改下
      

  2.   

    select c.classid,avg(a.score)as avgscore
    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
      

  3.   

    select c.classid,avg(h.score)as avgscore
    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
      

  4.   

    我想要得是那种带select * from ... where id in(select...)
      

  5.   

    select
        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
      

  6.   


    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
      

  7.   

    我是准备迁入到asp里的。不要戴带点的那种表示方式,要纯in()的那种,我写了一个,不对。
    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)
     )
      

  8.   

    --try
    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
      

  9.   

    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
    ----------------------------------
    楼主,最外层用了group by class.classid,而你的avg(choice.score)要从choice取数据,就注定了class、choice必须放在同一级处理,不应该用你所说的“要纯in()的那种”。不太明白楼主为什么一定要这种
      

  10.   

    如果choice中也有classid
    字段,倒是可以
      

  11.   

    这个是要放在asp中处理的,所以