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


Please Help Members By Posting Answers For Below Questions

Is sql a oracle?

527


what is isam? : Sql dba

574


What is the use of count (*) in sql?

549


How are functions and procedures called in PL/SQL?

593


What does fetching a cursor do?

617






What is relationship? How many types of relationship are there?

592


What is difference between table and view?

526


Why is normalization important?

541


What are the types of optimization?

521


What are types of indexes in sql?

539


what are aggregate and scalar functions? : Sql dba

552


What is function and procedure?

569


How do I know if I have sql express or standard?

604


What does closing a cursor do?

767


what are the features and advantages of object-oriented programming? : Sql dba

549