score 分数 sex性别 name名字
---------------------------------------------------------
select score,sex,name,max(score) from table group by sex这样试试?或者你union all试试
select name,sex,score from table where sex='f' order by score desc union allselect name,sex,score from table where sex='m' order by score desc limit 2
你这个相当于两个条件,所以就需要查询两次了,如果合并,这就需要子查询了。如下查询你修改一下应该就没有问题了
select * from table t where t.id in(select t.id from table t where t.gender='男' order by t. grade limit 5) or t.id in(select t.id from table t where t.gender='女' and order by t. grade limit 5)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)