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 / bibu
This IS HELP FULL 1ST ,2ND,3RD,4TH ANY HIGHEST SALARY U WRITE THIS QUERY.
SELECT * FROM Table_Name ALIAS_NAME 1
WHERE &N=(
SELECT COUNT(DISTINCT(WHICH COL U WANT THAT COL_NAME))
FROM Table_Name ALIAS_NAME 2
WHERE ALIAS1.CoL<=ALIAS2.Col
)
EX:
SELECT * FROM Emp E1
WHERE &N=(SELECT COUNT(DISTINCT(Sal))
FROM Emp E2
WHERE E1.Sal<=E2.Sal)
| Is This Answer Correct ? | 11 Yes | 0 No |
Post New Answer View All Answers
define sql insert statement ? : Sql dba
Is sql better than excel?
How would you pass hints to the sql processor?
What is a natural join sql?
How do you explain an index?
what are the difference between clustered and a non-clustered index? : Sql dba
How does stored procedure reduce network traffic?
Which command is used to delete a trigger?
Which software is used for pl sql programming?
what is the stuff function and how does it differ from the replace function? : Sql dba
what are enums used for in mysql? : Sql dba
Difference between table function and pipelined function?
Write a sql query to convert all character to uppercase after hypen.
what is the difference between blob and text? : Sql dba
What is a trigger word?