how to get second highest salary in SQL(as/4000
Answer Posted / s. syam sundar
1.SELECT LEVEL,MAX(SAL) FROM EMP WHERE LEVEL = 2 CONNECT BY
PRIOR SAL >SAL GROUP BY LEVEL
2.SELECT SAL FROM (SELECT SAL FROM EMP ORDER BY SAL DESC)
WHERE ROWNUM <3
MINUS
SELECT SAL FROM (SELECT SAL FROM EMP ORDER BY SAL DESC)
WHERE ROWNUM = 1
3.SELECT MAX(SAL) FROM EMP WHERE SAL <> (SELECT MAX(SAL)
FROM EMP)
regards
syam sundaar
| Is This Answer Correct ? | 4 Yes | 5 No |
Post New Answer View All Answers
Can instead of triggers be used to fire once for each statement on a view?
what are the advantages of mysql in comparison to oracle? : Sql dba
What are sql indexes?
What is a join query?
Can we create a trigger on view?
What does bitemporal mean?
What are different types of sql commands?
Explain the commit statement.
What is sql*loader and what is it used for? : aql loader
which tcp/ip port does sql server run on? : Sql dba
What is denormalization in a database?
How can you tell the difference between an index and a view?
what is the difference between undefined value and null value? : Sql dba
What is difference between hql and native sql?
Can we rename a column in the output of sql query?