学习到子查询的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;
输出正常!