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 are tables and fields? : Sql dba

1029


What is data control language?

971


What is the primary use of normalization?

983


What are the triggers associated with image items?

1030


How to add, remove, modify users using sql?

1021


What is rank dense_rank and partition in sql?

1006


how can we find the number of rows in a table using mysql? : Sql dba

1069


What is a column in a table?

1106


Do we need commit after truncate?

1063


What is the example of procedure?

908


What is native sql query?

1004


Does sql use python?

1013


What is the difference between count 1 and count (*) in a sql query?

963


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

1027


What is data manipulation language?

1171