This is my code:
BREAK ON DEPTNO SKIP 1
compute sum of sal on deptno
SELECT deptno, empno, ename,sal FROM
(SELECT deptno, empno, ename, sal FROM emp group by deptno, empno, ename, sal order by DEPTNO)
WHERE ROWNUM <= 2;
But the result is:
DEPTNO EMPNO ENAME SAL
---------- ---------- ---------- ----------
10 7782 CLARK 2450
7839 KING 5000
********** ----------
sum 7450
What is good, but I want to get also on deptno 20, deptno 30: (This is expected result, all in the same return - for deptno 10, 20,30)
DEPTNO EMPNO ENAME SAL
---------- ---------- ---------- ----------
10 7782 CLARK 2450
7839 KING 5000
********** ----------
sum 7450
DEPTNO EMPNO ENAME SAL
---------- ---------- ---------- ----------
20 7788 SCOTT 3000
7902 FORD 3000
7566 JONES 2975
********** ----------
sum 8975
DEPTNO EMPNO ENAME SAL
---------- ---------- ---------- ----------
30 7698 BLAKE 2850
7499 ALLEN 1600
********** ----------
sum 4450
My question is how to sum two highest salary on table EMP on deptno (deptno 10,20,30) using BREAK
and COMPUTE SUM
all in one return (just like expected above)?
I think my code is closely good, but is missing something.