how to find the second highest salary from emp table?
Answer Posted / kishan singh chilwal
SELECT MAX(sal)
FROM emp
WHERE sal <> (SELECT MAX(sal) FROM emp);
<> = not equal to
the SELECT statement in the WHERE clause will find the 1st max sal in the table
the 1st SELECT statement will find max sal in the table after excluding the first max sal
(ALTERNATE WAY)
SELECT MAX(sal)
FROM emp
WHERE sal not in (select max(sal) from emp );
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is user defined functions?
Explain the difference between drop and truncate commands in sql?
Does pdo prevent sql injection?
How to use sql statements in pl/sql?
How do you write a complex sql query?
what is a materialized view? : Sql dba
what are the differences between get and post methods in form submitting. Give the case where we can use get and we can use post methods? : Sql dba
how do you know the version of your mysql server? : Sql dba
Explain what is a subquery ?
What is compiled query?
what are the authentication modes in sql server? : Sql dba
List and explain the different types of join clauses supported in ansi-standard sql?
How many aggregate functions are available there in sql?
What is coalesce sql?
Is sql open source?