GROUP BY 是分组,主要用于统计,合计等SQL中使用
比如:
select userid,count(*) as cnt from usercount group by userid;
order by 是排序,即按什么字段来排序,顺序或倒序。
在group by 中可以使用order by
如:
select userid,count(*) as cnt from usercount group by userid order by cnt (倒序时添加 desc)
group by 是按。。。分组的意思,order by 是按。。。排序的意思
group by 单词就是将表按单词分成几个组
order by A,B,C 就是 先按A排序,再按B排序,再按C排序
GROUP BY 是分组,ORDER BY 是排序,分组后,相同关键字将唯一,排序有多少条数据不变.