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
what is sql in mysql? : Sql dba
difference between anonymous blocks and sub-programs.
What is t sql in sql server?
What is varchar example?
Show code of a cursor for loop.
what are ddl statements in mysql? : Sql dba
How many commands are there in sql?
What is sql and also describe types of sql statements?
Why we use stored procedure instead of query?
Explain the difference between sql and mysql.
Why we use pl sql?
How to select 10 records from a table?
Can you inner join the same table?
Describe sql comments?
When are we going to use truncate and delete?