Group by规则,出现在select列表中的字段,如果查询列没有出现主函数中,就必须出现在group by 列表中。
select deptno,avg(sal) from emp group by deptno; deptno换成ename就报错。
Having 对group by进行限制。
select avg(sal),deptno from emp group by deptno havingavg(sal) > 2000;
Group by规则,出现在select列表中的字段,如果查询列没有出现主函数中,就必须出现在group by 列表中。
select deptno,avg(sal) from emp group by deptno; deptno换成ename就报错。
Having 对group by进行限制。
select avg(sal),deptno from emp group by deptno havingavg(sal) > 2000;