1. select age,max(id),min(id),count(id),sum(id),avg(id) from info group by age;
    1. select age,count(1) from info group by age;
    1. select depart_id,count(id) from info group by depart_id;
    1. select depart_id,count(id) from info group by depart_id having count(id) > 2;
    1. select count(id) from info;
    2. select max(id) from info;
    1. select age,max(id),min(id),sum(id),count(id) from info group by age;
    1. select age,name from info group by age; -- 不建议
    2. select * from info where id in (select max(id) from info group by age);
    1. select age,count(id) from info group by age having count(id) > 2;
    2. select age,count(id) from info where id > 4 group by age having count(id) > 2; -- 聚合条件放在having后面
    1. 到目前为止SQL执行顺序:
    2. where
    3. group by
    4. having
    5. select
    6. order by
    7. limit
    1. select age,count(id) from info where id > 2 group by age having count(id) > 1 order by age desc limit 1;
    2. - 要查询的表info
    3. - 条件 id>2
    4. - 根据age分组
    5. - 对分组后的数据再根据聚合条件过滤 count(id)>1
    6. - 根据age从大到小排序
    7. - 获取第1