find out the second highest salary?

Answer Posted / priyankur

@peter: your query is pretty cool but it wont work when
there are multiple salaries with same amount. I mean three
persons have same salary 24000, which is MAX sal in salary
table. In that case, below query will work.

select a.salary from employees a where 1 = (select count
(distinct b.salary) from employees b where
a.salary<b.salary)

Digit 1 is (n-1) where n is nth value. Here n is 2(Second
highest salary).

I would appreciate if anybody tried to break my above query
and explain how does this work.

Is This Answer Correct ?    7 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are oracle functions?

553


What are joins, explain all types of joins?

1724


How to use regular expression in pattern match conditions in oracle?

575


does the query needs a hint to access a materialized view?

1467


Explain the characteristics of oracle dba?

636






Please explain joins in oracle?

547


What is a sub query and what are the different types of subqueries?

624


What is translate in oracle?

619


What is not equal to in oracle?

526


How to use "in" parameter properly?

617


How to use "while" statements in oracle?

737


How do we create privileges in oracle?

588


How to set a transaction to be read only in oracle?

582


In SAP ECC 6.0 , under DB02 tcode , Tablespace name to be explain stepy step all the col

3700


How to use "startup" command to start default instance?

542