首页 新闻 会员 周边 捐助

统计男女人数

0
[待解决问题]

String sql="(select * from info where (select count() from info where studentSex='男')>(select count() from info where studentSex='女') order by studentSex desc) "; String sql2="(select * from info where (select count() from info where studentSex='男')<(select count() from info where studentSex='女') order by studentSex)"; 根据性别,男生多的话男生就在表的最前面,反之,女生在最前面,一样多的话,就按插入数据的顺序排列,怎样用一句sql语句写

东方411的主页 东方411 | 菜鸟二级 | 园豆:204
提问于:2018-07-24 23:18
< >
分享
所有回答(1)
0

SELECT studentSex, COUNT(*) AS num FROM info
GROUP BY studentSex
ORDER BY studentSex ASC

大豆男生 | 园豆:608 (小虾三级) | 2018-07-25 10:00
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册