-- 多子句查询顺序
SELECT column1, column2,... FROM mytable
GROUP BY columnx
HAVING conditionx
ORDER BY columnx
LIMIT startx, rowsx;
-- 统计各个部门平均工资,并且大于1000, 并且按照最低工资从高到低排序,取出前两条记录
SELECT AVG(sal) AS avg_sal, deptno
FROM emp
GROUP BY deptno
HAVING avg_sal > 1000
ORDER BY avg_sal DESC
LIMIT 0, 2
标签:GROUP,sal,查询,LIMIT,avg,多子
From: https://www.cnblogs.com/pureayu/p/17122331.html