sql带有group by,那么select里头只能包含group by by的列或者是聚合函数
select max(id) id, catid from post group by catid order by id desc;
写的顺序:select ... from... where.... group by... having... order by..
执行顺序:from... where...group by... having.... select ... order by...
编写过程:select distinct ... from ... join ... on ... where.... group by ... having ... order by ... limit ...
解析过程:from ... on ... join ... where.... group by... having ... select distinct ... order by... limit ...