how to find the second highest salary from emp table?

Answer Posted / neil

select * from (select sal,deptno from emp a where
sal in (select distinct(b.sal) from emp b
where a.deptno=b.deptno and rownum<4)
order by deptno,sal desc )
minus
select * from (select sal,deptno from emp a where
sal in (select distinct(b.sal) from emp b
where a.deptno=b.deptno and rownum<3)
order by deptno,sal desc )

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are packages in pl sql and also explain its advantages?

532


What is plpgsql language?

529


What does bitemporal mean?

595


What is sql query optimization?

541


How to run sql commands in sql*plus?

585






What are the basic techniques of indexing?

575


What is a table in a database?

575


explain the delete statements in sql

578


What is the difference between in and between in sql?

574


Is inner join same as self join?

578


What is an inconsistent dependency?

579


Can we create view in stored procedure?

524


How do you update a sql procedure?

521


What is nested table in pl sql?

553


What is break?

616