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
An automatic job running via DBMS_JOB has failedKnowing only that its failed, how do you approach troubleshooting this issue?
What is bulk copy or bcp in oracle?
How to create a stored procedure in oracle?
What are triggers in oracle?
What happens if you lost a data file?
How do I spool in oracle?
Using the relations and the rules set out in the notes under each relation, write table create statements for the relations EMPLOYEE, FIRE and DESPATCH. You should aim to provide each constraint with a formal name, for example table_column_pk.
How to convert a date to char in oracle? Give one example.
What is snapshot is too old? Give and example for better understand.
What is a cursor in oracle?
Explain mutating triggers.
How to write text literals in oracle?
How can you tell how much space is left on a given file system and how much space each of the file systems subdirectories take-up?
Is truncate autocommit in oracle?
What are the different pseudo commands? Explain in general?