select emp.ename, emp.sal ,dept.deptno from emp,dept where emp.deptno=dept.deptno group by dept.deptno 如果你用到group by 语句 要查询的字段必须加聚合函数 比如 select sum(emp.sal) ,dept.deptno from emp,dept where emp.deptno=dept.deptno group by dept.deptno
Group by规则,出现在select列表中的字段,如果查询列没有出现主函数中,就必须出现在group by 列表中。
如果你用到group by 语句 要查询的字段必须加聚合函数 比如
select sum(emp.sal) ,dept.deptno from emp,dept where emp.deptno=dept.deptno group by dept.deptno