日期:2014-05-16 浏览次数:21193 次
select a.classId from (select classId,count(*) as cnt from 表结构 where sex='男' group by classId) a , (select classId,count(*) as cnt from 表结构 where sex='女' group by classId) b where a.classId=b.classId and a.cnt=b.cnt
------解决方案--------------------
SELECT classId FROM TTH
GROUP BY classId HAVING SUM(IF(sex='男',1,0))=SUM(IF(sex='女',1,0))