以1代表'男'和2代表'女', 来代替字段sex的值,
我做的比较啰嗦 不过结果出来了,以下仅供参考:
select aaa.classid from (select classid,count(*) as shu from student where sex='1' group by classid) as aaa,(select classid,count(*) as shu from student where sex='2' group by classid) as bbb where aaa.shu >bbb.shu and aaa.classid=bbb.classid
用select语句查询
select sum(年龄),班级,性别 from Table1 where 班级='A' or 班级='B' group by 班级,性别
select sum(年龄),班级,性别 from Table1 where 班级='A' or 班级='B' group by 班级,性别
select classid
from student
where (select count(sex) from student where sex ='男') > (select count(sex) from student where sex ='女')