HOW TO DISPLAY MAXIMUM SALARIES FROM EMP DEPARTMENT VISE ALONG
WITH DEPARTMENT NAMES? E.g EMP,DEPT
Answers were Sorted based on User's Feedback
Answer / naveen
SELECT D.DEPTNO,D.DNAME,MAX(SAL) FROM EMP E,DEPT D WHERE
D.DEPTNO=E.DEPTNO GROUP BY D.DEPTNO,D.DNAME;
Is This Answer Correct ? | 17 Yes | 1 No |
Answer / rajiv
select dept.dname,max(sal) totalsal from emp,dept where dept.deptno=emp.deptno group by dept.dname;
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / harika
select dname,max(sal) from emp e,dept d
where d.deptno=e.deptno
group by d.deptno;
Is This Answer Correct ? | 3 Yes | 6 No |
In oracle 10g :
SELECT * FROM
(SELECT DEPTNO,
EMPNO,
ENAME,
SAL,
DENSE_RANK() OVER(PARTITION BY DEPTNO ORDER BY SAL
DESC) RANK
FROM EMP);
OUTPUT :
------------>
DEPTNO EMPNO ENAME SAL RANK
---------- ---------- ---------- ---------- ----------
10 7839 KING 5000 1
10 7782 CLARK 2450 2
10 7934 MILLER 1300 3
20 7788 SCOTT 3000 1
20 7902 FORD 3000 1
20 7566 JONES 2975 2
20 7876 ADAMS 1100 3
20 7369 SMITH 800 4
30 7698 BLAKE 2850 1
30 7499 ALLEN 1600 2
30 7844 TURNER 1500 3
DEPTNO EMPNO ENAME SAL RANK
---------- ---------- ---------- ---------- ----------
30 7521 WARD 1250 4
30 7521 WARD 1250 4
30 7654 MARTIN 1250 4
30 7900 JAMES 950 5
15 rows selected.
Is This Answer Correct ? | 0 Yes | 4 No |
What is the difference between formal parameters and actual parameters?
What is a Segment ?
What is a Synonym ?
How to check the server version in oracle?
What are synonyms used for ?
Youre getting high busy buffer waits - how can you find whats causing it?
Can we convert a date to char in oracle and if so, what would be the syntax?
Why cursor variables are easier to use than cursors?
How to assign a tablespace to a users in oracle?
What are the execution control statements in oracle?
What is SAVE POINT ?
How to define default values for formal parameters?