学习到子查询的
from查询
要求:表中信息先排序,再分组:默认取第一个
select * from (select * from student order by stu_height asc ) as hehe group by class_id;
查询成功,不过仔细比对数据过后,发现
group by 语句并没有生效;
括号内的查询内容也正常
解决方案:在order by 语句后面,加上limit 限制!【 0:第一个开始; 100:(尽可能大)往下数100个】
select * from (select * from student order by stu_height asc limit 0,100) as hehe group by class_id;
输出正常!
版权声明:本文为baidu_41858278原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。