如果列为 a 的数据有很多条,就会发现最终取到的那条数据可能不是 updated_at 最近的那条数据,因为 distinct 有一次默认的排序,然后生成一个临时表,然后 order by 无法从最开始的原始数据中进行排序,仅排序中间表,无法得出正确结果。改成 distinct a, updated_at 的话,实际上又失去了 distinct 的意义了。
在 MySQL 5.7版本以上进行一些 ORDER BY 或者 GROUP BY 时,会出现如下错误 [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ‘information_schema.PROFILING.SEQ’ which is not functionally dependent on columns in GROUP BY clause; this is incompatib...