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


Please Help Members By Posting Answers For Below Questions

what is a database lock ? : Sql dba

585


What is meant by user defined function?

575


how to get help information from the server? : Sql dba

524


What is the execution plan in sql?

550


Can pl sql procedure have a return statement?

545






Can we create foreign key without primary key?

526


What is meant by truncate in sql?

520


Is full outer join same as cross join?

497


what is sql? : Sql dba

553


Is oracel sql developer written in java?

640


What are the built in functions of sql?

551


what tools available for managing mysql server? : Sql dba

522


what is the stuff function and how does it differ from the replace function? : Sql dba

615


Is crud a cuss word?

539


What is record in pl sql?

587