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
how to use in conditions? : Sql dba
Why functions are used in sql?
How to fetch values from testtable1 that are not in testtable2 without using not keyword?
Does mysql support pl sql?
Are views faster than queries?
what happens if you no create privilege in a database? : Sql dba
What are all different types of collation sensitivity?
Can you call pl/sql package functions from within a fast formula?
what is recursive stored procedure? : Sql dba
How to pronounce postgresql?
How many types of cursors are available in pl/sql?
What is a schema sql?
What is rownum in sql?
What is information schema in sql?
Does view store data in sql?