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

what is sql in mysql? : Sql dba

571


difference between anonymous blocks and sub-programs.

622


What is t sql in sql server?

571


What is varchar example?

576


Show code of a cursor for loop.

584






what are ddl statements in mysql? : Sql dba

579


How many commands are there in sql?

549


What is sql and also describe types of sql statements?

565


Why we use stored procedure instead of query?

538


Explain the difference between sql and mysql.

567


Why we use pl sql?

529


How to select 10 records from a table?

650


Can you inner join the same table?

527


Describe sql comments?

561


When are we going to use truncate and delete?

553