find out the second highest salary?

Answer Posted / hari kanth

select sal from(select sal,rank() over(order by sal desc)
rnk from emp) e
where e.rnk=2;
(OR)
select rownum,sal from emp group by sal,rownum
having rownum=2;
(OR)
select rn,sal from( select rownum rn,sal from emp group by
sal,rownum order by sal desc)
where rn=2;

Is This Answer Correct ?    3 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to add another datafile to a tablespace?

585


What is redo log?

638


Can we write dml statement in function in oracle?

642


Explain table?

668


Explain the use of parfile option in exp command.

535






What is a sub query? Describe its types?

556


What is transport network substrate (tns) in oracle?

597


Why cursor variables are easier to use than cursors?

579


What is a database schema in oracle?

632


What happens if the update subquery returns multiple rows?

622


How to create a stored procedure in oracle?

587


why should i declare foreign key constraint as self relation instead of binary relation in tables ?

1582


Explain an index segment?

655


What is the difference between the Oracle ODBC driver and a Microsoft ODBC (Open Database Connectivity) Driver?

626


What is the difference between $oracle_base and $oracle_home?

595