Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How to retrieve a second highest salary from a table?
Note:Suppose salaries are in duplicate values
eg:
Name Sal
Malli 60000
Pandi 60000
Rudra 45000
Ravi 45000

Answer Posted / mallinathabj

The Following queries to retrieve the second highest salary

SQL> select max(sal) from emp where sal<(select
max(distinct(sal)) from emp);

SQL> select min(sal) from(select distinct( sal) from emp order
by sal desc) where rownum<=2;

SQL> SELECT MAX(SAL) FROM EMP WHERE SAL NOT IN (SELECT
MAX(SAL) FROM EMP);

Is This Answer Correct ?    13 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is top in tsql? : Transact sql

1113


Write the alter statement to enable all the triggers on the t.students table.

1123


What are different types of indexes?

1006


What is group by in sql?

1083


What is coalesce sql?

995


what is union? : Sql dba

1025


What is trigger in sql and its types?

1055


what is cursor. write example of it. What are the attributes of cursor.

1381


Is not null in sql?

990


what is dbms? : Sql dba

989


How does rowid help in running a query faster?

1416


What is database white box testing and black box testing?

1107


What is trigger in sql?

1095


Explain the insert into statements in sql?

1005


how to fetch alternate records from a table? : Sql dba

1107