select school_id,count(stu_sex) as scount from stu where (school_id,count(stu_sex)) =(select school_id ,count(stu_sex) as count from stu group by school_id order by count desc limit 1) group by stu_sex;提示: Utilisation invalide de la clause GROUP,这是啥意思?
3 回答
已采纳
KevenHuang
TA贡献280条经验 获得超233个赞
写这么复杂的sql语句,如果有实际需求而且不影响性能的情况尚可,但是如果性能很差,这样的sql语句必然会被诟病,所以,如果没有实际项目需求,这种sql语句一定要尽量避免,再者,有可能自己都看不懂,扰乱自己的思维。
慕粉1003216417
TA贡献1条经验 获得超1个赞
select school_id,count(stu_sex) as scount
from stu
-- where (school_id,count(stu_sex)) =(select school_id ,count(stu_sex) as count from stu group by school_id order by count desc limit 1)
group by stu_sex;
把where条件先注释掉,你就发现你写的已经错了,简单查询先写好,再加where条件,还有,两个字段组合的等值写法是没有的,你可以试试用left join
添加回答
举报
0/150
提交
取消