SELECT 班级ID,班级名称,学生数=(SELECT COUNT(*) FROM 学生表 WHERE CLASSID=班级表.CLASSID)FROM  班级表

解决方案 »

  1.   

    根本就不能用一条SELECT语句来实现的
      

  2.   

    select a.classid 班级ID,a.classname 班级名称,nvl(b.studentno,0) 学生数 from class a,
    (
      select classid,count(0) studentno from student group by classid
    ) b
    where a.classid=b.classid(+);
      

  3.   

    试试这个
    select a.classid,a.classname,count(b.classid)
    from class a,student b
    where a.classid = b.classid
    group by a.classid,a.classname
      

  4.   

    select a.classid, a.classname, count(b.studentid) from class a,student b
    where a.classid = b.classid group by a.classid,a.classname