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
How do I trace sql profiler?
How do you create a unique index?
what are all the different normalizations? : Sql dba
What are the benefits of stored procedures?
Explain the working of primary key?
What is the difference between rename and alias?
How much ram can sql express use?
what are properties of a transaction? : Sql dba
What is string data type in sql?
What is the difference between null value, zero, and blank space?
What are records give examples?
what is a database lock ? : Sql dba
How do I find duplicates in two columns?
what is rollback? : Sql dba
How can you fetch first 5 characters of the string?