MySQL的分组和排序

分组操作

  select count(id) from userinfo group by pat(id);
   -- 聚合函数:
    --count
    --max
    --sum
    --avg
    ---如果对于二次函数进行二次筛选时>,必须使用having
    select  count(id) from userinfo group by part_id having count(id)>1;

排序操作

select * from ta1 order by id desc --从大到小根据id排序
  --asc 从小到大
原文地址:https://www.cnblogs.com/tataerzu/p/10165574.html