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 scope of pl sql developer in future?

1070


What are different types of queries in sql?

1174


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

1184


How do you bind variables in pl sql?

1160


Explain locks? : Transact sql

1054


How does sql profiler work?

1065


How many sql are there?

1052


Explain autonomous transaction.

1220


What is the difference among union, minus and intersect?

1049


What is varray in pl sql?

1120


Define join and name different types of joins?

1054


What is the difference between the conventional and direct path loads? : aql loader

1473


How many indexes can be created on a table in sql?

1114


What is pl sql commands?

1097


What does fetching a cursor do?

1133