How to retrieve a second highest salary from a table?
Note:Suppose salaries are in duplicate values
eg:
Name Sal
Malli 60000
Pandi 60000
Rudra 45000
Ravi 45000
Answer Posted / shriram
You can also do it by the following query ..
select * from (select name,salary,rank() over(order by
salary desc as r) from employee) where r = 2;
The above query returns the 2nd highest salary from the table.
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
Does sql support programming?
Explain the difference in execution of triggers and stored procedures?
What is the usage of distinct keyword?
What do you understand by pl/sql packages?
How do you use join?
What jobs use sql?
What is null in pl/sql?
how can you create an empty table from an existing table? : Sql dba
What is primary key and foreign key with example?
What will you get by the cursor attribute sql%notfound?
Why truncate is used in sql?
How do I find sql profiler?
write an sql query to get third maximum salary of an employee from a table named employee_table. : Sql dba
What is difference between sql function and stored procedure?
How many row comparison operators are used while working with a subquery?