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 find the second highest salary from emp table?

Answer Posted / bharath reddy

These qeries give you second higest salary

select e.sal from emp e,emp d where d.sal>e.sal
group by e.sal
having count(e.sal)=2
;

SAL
-----
3000

(or)

select distinct e.sal from emp e where (select count(sal)
from emp d where d.sal>e.sal)=1;

SAL
-----
3000

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we use joins?

1033


Which is faster count (*) or count 1?

1030


What are packages in pl sql and also explain its advantages?

1035


How to run sql functions in pl/sql?

1052


How do you define a foreign key?

996


What is meaning of <> in sql?

1067


Why do you partition data?

1016


Is pl sql different from sql?

994


How to rename a column in the output of sql query?

1072


What is the purpose of the sql select top clause?

1108


What is the difference between mdf and ndf files?

1115


Can unique keys be null?

908


How do you modify a table in sql?

1118


How many parts of a pl sql block are optional?

1128


How do I install microsoft sql?

1050