order by group by 同时使用的方法
的有关信息介绍如下:GROUP BY 和 ORDER BY同时使用的方法及注意事项:
GROUPBY和ORDERBY同时存在的情况是,ORDER BY对GROUPBY后的结果再进行排序,所以ORDERBY后面的排序字段需要在SELECT里出现,ORDERBY子句中的列必须包含在聚合函数或GROUPBY子句中。
例如:
slect * from table group by type,id order by id
slect * from table group by type,id order by type