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
How many objectname will be created for a single table drop function? Why 'flashback' query giving error "ORA-38312: original name is used by an existing object" while getting the table?
Why do we need integrity constraints in a database?
What is coalesce function?
what's query optimization and without use of IN AND Exist can we get another way data from query
List out the types of joins.
Can we save images in a database and if yes, how?
How to get last row id?
List the types of joins used in writing subqueries?
How can we force the database to use the user specified rollback segment?
Briefly explain what is literal? Give an example where it can be used?
11. Display the client number and name and the client number and name of the person who referred that client.
how may join possible between (requisition with purchase order)
Can you tell me how to add new column in existing views?how?How is possible?
How to view the data files in the current database?
Explain the use of indexes option in imp command.