select distinct d.dname , count(e.ename)over(partition by d.deptno order by d.deptno) as rn , avg(e.sal)over(partition by e.deptno order by e.deptno) as sal from emp e ,
dept d where d.deptno = e.depeno(+)
测试通过~~ ------解决方案--------------------
你把部门表和员工信息表通过部门号关联就行了,我已经试验成功了。
SELECT d.dname 部门名称, COUNT(*) 部门人数,AVG(T.SAL) 平均工资
FROM EMP T,dept d
WHERE t.deptno=d.deptno
GROUP BY d.dname
------解决方案--------------------
这个是group by 的基础语法,如果你用了聚合函数,那么你group by 部分的字段 得和select 一致
比如
select d.dname , d.no , count(*) from dual group by d.dname , d.no