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
Which is better trigger or stored procedure?
What is data control language?
What is trigger and types?
Is it mandatory for the primary key to be given a value when a new record is inserted?
How do I tune a sql query?
What is trigger price?
how to convert numeric values to character strings? : Sql dba
What is the sql query to display the current date?
What are all different types of collation sensitivity?
Can a table contain multiple foreign key’s?
How many parts of a pl sql block are optional?
What is not equal in sql?
how can we find the number of rows in a table using mysql? : Sql dba
what are the differences among rownum, rank and dense_rank? : Sql dba
What is the most common sql injection tool?