经常会遇到需要对数据先排序后分组的情况,正常情况下执行下面的SQL便可以 SELECT * from (SELECT * FROM `jr_interview_operation` WHERE ( `interview_id` = 26 AND `type` = 3 ) AND `jr_interview_operation`.`delete_time` = 0 ORDER BY `id`
经常会遇到需要对数据先排序后分组的情况,正常情况下执行下面的SQL便可以
SELECT * from (SELECT * FROM `jr_interview_operation` WHERE ( `interview_id` = 26 AND `type` = 3 ) AND `jr_interview_operation`.`delete_time` = 0 ORDER BY `id` desc ) a group by a.person_id
但是实际使用时,子查询中的排序并没有生效,这是由于mysql5.7以后优化掉了子查询中的排序操作。
需要使用子查询中的排序操作的话加上limit语句就可以
SELECT * from (SELECT * FROM `jr_interview_operation` WHERE ( `interview_id` = 26 AND `type` = 3 ) AND `jr_interview_operation`.`delete_time` = 0 ORDER BY `id` desc limit 0,1000 ) a group by a.person_id
未经允许不得转载:任鹏个人博客 » Mysql5.7先排序order by 后 group by,但是排序不生效
最新评论
Forex wiki. https://lt.forex-stock-bitcoin-brokers.com
Magnificent items from you, man. I have take note your stuff
Following on from the 3rd March Meetings held by economic de
It is remarkable, rather valuable message dfgdlfg2131.32
一般都会有一个沙盒期的,过了沙盒期就会慢慢放出来
百度不收录是应为是新站的原因吗?
The spike in consumer prices that left inflation at a four-d