sql - Oracle - how to calculate sum of highest salary for each dept -
as far get, getting max sal of each dept:
select ename, sal, deptno emp out sal = ( select max(sal) emp inside out.deptno=inside.deptno );
this returns 4 results, want sum of 4 results, how do that? seems not work:
select ename, sum(sal), deptno emp out group deptno, sal, ename having sum(sal) = ( select max(sal) emp inside out.deptno=inside.deptno );
it returning same result first query.
select sum(max_sal) total_sum ( select deptno, max(sal) max_sal emp group deptno ) x
to highest salary every department can group department , use max()
highest. use subquery sum these up.
Comments
Post a Comment