group和order一起使用问题
group 的执行优先级大于order的优先级,所以在执行sql语句时会先进行group分组然后在进行order排序操作
SELECT * FROM `table_name` GROUP BY `session_list` ORDER BY `create_time` ASC
1
需要对查询数据先进行排序操作后再进行分组操作
SELECT
*
FROM
(SELECT * FROM `table_name` ORDER BY `create_time` DESC LIMIT 1000) AS record
GROUP BY
`session_list`