how to get second highest sal of emp table

Answers were Sorted based on User's Feedback



how to get second highest sal of emp table..

Answer / yadunandan

select max(sal) from emp where sal<(select max(sal) from
emp)

Is This Answer Correct ?    4 Yes 2 No

how to get second highest sal of emp table..

Answer / anilchandu

Select * from emp x where 2=(select count(distinct sal)
from emp y where x.sal<=y.sal)


where x,y are alias names.

If you want 3rd heighest salary then just replace 2 by 3

Is This Answer Correct ?    2 Yes 0 No

how to get second highest sal of emp table..

Answer / manjeet

select max(sal) from emp where sal not in (select max(sal)
from emp)

Is This Answer Correct ?    1 Yes 0 No

how to get second highest sal of emp table..

Answer / prabhudatta barick

--IN ORDER TO FIND THE NTH HIGHEST SALARY,
--WE JUST FIND THE SALARY THAT HAS EXACTLY N-1 SALARIES
GREATER THAN ITSELF---

--This is correlated subquery--
select empno,
ename,
sal
from scott.emp e
where &n-1=(select count(distinct b.sal) from scott.emp b
where b.sal>e.sal);

To get second highest salary put n value 2.

Is This Answer Correct ?    1 Yes 0 No

how to get second highest sal of emp table..

Answer / rakhi

SELECT *
FROM (
SELECT employee_id, last_name, salary,
RANK() OVER (ORDER BY salary DESC) EMPRANK
FROM employees)
WHERE emprank = 2;

Is This Answer Correct ?    2 Yes 2 No

how to get second highest sal of emp table..

Answer / amit bhagat

select min(a.sal) from (select disctinct d.sal from emp d
order by sal desc) a where rownum<=2

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Oracle General Interview Questions

find out the second highest salary?

55 Answers   Cognizant, Nucsoft, Oracle, TCS, Wondersoft,


Is a rollback possible to any savepoint?

0 Answers  


Why does Oracle not permit the use of PCTUSED with indexes?

0 Answers  


which sql command we can use to get a print out from oracle?

2 Answers   iFlex, INDUS,


Can we protect our pl/sql source code?

0 Answers  






what is the difference between sql& oracle?

11 Answers   Oracle,


I have some query regarding Report generation from Oracle Apps "PO module". I have to generate a report where table columns are as below: Vendor_name Invoice No PO Number Item_Quantity Value of Goods Date of Shipping Name_of_the_transport Date_of_receipt_issued. Now my questions is :from which table/column I can get the information of "Name_of_the_transport" column. Thanks in advance.

0 Answers  


Hi, I want table structure shown below. How can i create this ? Num Name Address Addr1 Addr2 I want Addr1 and Addr2 under Address column. How can i achive this ? Is it possible ?

2 Answers   IBM,


What is oracle rownum?

0 Answers  


How to rename an index?

0 Answers  


What are a collation and state the different types of collation sensitivity?

0 Answers  


how to truncate date and get only time part 9:20:00

5 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)