在学生信息表(XSXXB)统计个班男生人数和女生人数,
更新班级信息表(BJXXB)中各班的男生人数和女生人数谢谢

解决方案 »

  1.   

    update BJXXB
    set 男生人数=(select sum(1) from XSXXB where 性别=男生),
     女生人数=(select sum(1) from XSXXB where 性别=女生)
      

  2.   

    update BJXXB
    set 男生人数=(select sum(1) from XSXXB where 性别='男生' and 班级=bjxxb.班级),
    女生人数=(select sum(1) from XSXXB where 性别='女生' and 班级=bjxxb.班级)
      

  3.   

    update A set 男生人数=B.男生人数,女生人数=B.女生人数 from BJXXB A INNER JOIN (select 班级,sum(男生人数) 男生人数,sum(女生人数) 女生人数 from XSXXB group by 班级) B ON A.班级=B.班级
      

  4.   

    update BJXXB 
    set 男生人数=(select sum(1) from XSXXB where 性别='男生' and 班级=bjxxb.班级), 
    女生人数=(select sum(1) from XSXXB where 性别='女生' and 班级=bjxxb.班级)