find the second highest salary of the emp table

Answers were Sorted based on User's Feedback



find the second highest salary of the emp table..

Answer / guest

ANS:
select max(salary) from Employees
where salary not in
(select max(salary) from Employees )

Is This Answer Correct ?    9 Yes 3 No

find the second highest salary of the emp table..

Answer / ramesh.ch

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


explanation::

first sub query returns maximum salary of employee
than main query returns maximum salary lessthan the maximum
salary return by subquery

Is This Answer Correct ?    6 Yes 1 No

find the second highest salary of the emp table..

Answer / ramesh mopuri

okay above queries are fine
but in a table there are 99 salaries, so i want to pick the
50th highest salary is it possible to wright the query same
above for the get 50th high salary. absolutely not. see my
query for the get Nth salary in a table.

Select ename,sal,deptno from emp a
where &n=
(select count(distinct(sal))from emp b
where a.sal<=b.sal)
order by deptno;

after enter this query the system ask N value and give 50
the result will be shown 50th highest salary. Please reply
me whether its working or not.

Is This Answer Correct ?    5 Yes 1 No

find the second highest salary of the emp table..

Answer / gyana ranjan behera

sql>select ename,sal from(select ename,sal,rownum rn from
(select ename,sal from emp order by sal desc)
where rn=2;

Is This Answer Correct ?    0 Yes 0 No

find the second highest salary of the emp table..

Answer / naresh

Here it is the simple solution.

Select Salary from (Select Salary, Rownum from Employee
order by Salary desc) where rownum=2

Should Work
Cheers!
Naresh

Is This Answer Correct ?    0 Yes 0 No

find the second highest salary of the emp table..

Answer / chiru

select distinct sal
from Employee e1
where 3 = (select count(distinct sal) from Employee e2
where e2.sal >= e1.sal)
order by sal desc

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Oracle General Interview Questions

how table is defined in plsql table? how can i select column from plsql table? can i use select * from plsql table type?

1 Answers  


1) What is ONE_SIZE_FITS_ALL approach? 2) Explain the Common & Variable Header of DATA FILE? 3) What are the Drawbacks to using OMF DB? and the Advantages? 4) List out the Advantages of Undo T.spaces over the Undo SEGMENT? 5) Difference between the Temporary tablespace with TEMPFILE and the Tablespace with TEMPORARY Keyword? 6) What are the situation extents are freeing for reuse.

0 Answers   TCS,


Name the various constraints used in oracle?

0 Answers  


Oracle

0 Answers   ABC, Genpact, HUI, Oracle,


How to restrict the duplicate records in table valuesets

2 Answers   IBM,






What is difference between UNIQUE constraint and PRIMARY KEY constraint ?

3 Answers  


What is Database Link ?

2 Answers  


what is the difference between data migration and production migration.

0 Answers  


What is a nvl function?

0 Answers  


Why does for update in oracle 8 cause an ora-01002 error?

0 Answers  


What is a Database instance ? Explain?

3 Answers  


What are the differences between date and timestamp in oracle?

0 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)