Answer Posted / neetika vardhan
SELECT DEPT, MAX(SAL)
FROM EMP
WHERE SAL NOT IN (SELECT MAX(SAL) FROM EMP GROUP BY DEPT)
GROUP BY DEPT
UNION
SELECT DEPT, MAX(SAL)
FROM EMP
GROUP BY DEPT
UNION
SELECT DEPT, MAX(SAL)
FROM EMP
WHERE SAL NOT IN
(SELECT MAX(SAL)
FROM EMP
WHERE SAL NOT IN (SELECT MAX(SAL) FROM EMP GROUP
BY DEPT)
GROUP BY DEPT
UNION
SELECT MAX(SAL) FROM EMP GROUP BY DEPT)
GROUP BY DEPT
| Is This Answer Correct ? | 0 Yes | 6 No |
Post New Answer View All Answers
What are all the common sql functions?
What is sqlservr exe?
What are the types of queries in sql?
what is an execution plan? When would you use it? How would you view the execution plan? : Sql dba
Which one is better subquery or joins?
What is flag in sql?
How does a self join work?
how to create a table index in mysql? : Sql dba
Does sap use sql?
Is json a nosql?
What are sql functions? Describe in brief different types of sql functions?
Which operator is used in query for pattern matching?
Do we need to create index on primary key?
How many types of sql are there?
Are ddl triggers fired for ddl statements within a pl/sql code executed using the dbms.sql package?