how to find the second highest salary from emp table?

Answer Posted / pranav damele

All the above one works with Oracle; this one is for MYSQL

second highest :
mysql> select * from employee group by salary desc limit 1,1;

limit 1,1; first '1' means that bring cursor to the end of record and the next '1' means number of records to be printed after the cursor position.

third highest:
mysql> select * from employee group by salary desc limit 2,1;

limit 2,1; '2' means that bring cursor to the end of 2nd record and the next '1' means number of records to be printed after the cursor position.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain spool.

691


what is a relationship and what are they? : Sql dba

553


What is the use of index in sql?

561


Can a foreign key be null?

593


Can a key be both primary and foreign?

510






What are the usages of sql?

567


How to connect a sql*plus session to an oracle server?

625


Can we write ddl statements in functions?

569


Can a table contain multiple primary key’s?

631


What is compiled query?

523


Does sql full backup truncate logs?

533


Can we create index on primary key?

524


what is the use of set statement in tsql? : Transact sql

538


What is a natural join?

518


Define implicit and explicit cursors.

633