select ename, deptno, sal,
sum(sal) over --overall running total, no partition
(order by deptno, ename) running_total,
sum(sal) over --running total by deptno w/ partition
(partition by deptno
order by ename) department_total,
avg(sal) over --avg for the dept
(order by deptno) avg_sal,
avg(sal) over --running average
(order by deptno, ename) running_avg
from emp
order by deptno, ename;
Result set is located here: http://dbaforums.org/oracle/index.php?s=&showtopic=20307&view=findpost&p=60489
No comments:
Post a Comment