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语句写
SELECT studentSex, COUNT(*) AS num FROM info
GROUP BY studentSex
ORDER BY studentSex ASC