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 / dsr

query:
======
select e.name,e.salary from emp e where &n =(select
count(distinct ee.salary) from emp ee where e.salary<=e.salary)

after run enter n value:

if 2 enter second max salary will come
if 3 enter third max salary will come.

otherwise, we can write below

select e.name,e.salary from emp e where 2 =(select
count(distinct ee.salary) from emp ee where e.salary<=e.salary)

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are the limitations of mysql in comparison of oracle? Mysql vs. Oracle. : Sql dba

903


What are keys in sql?

946


Explain lock escalation? : Transact sql

1144


how to convert character strings to dates? : Sql dba

985


Can %notfound return null after a fetch?

1005


What are the different set operators available in sql?

974


what is the bond code in materialized view?

2933


What is a behavioral trigger?

932


Name three sql operations that perform a sort.

959


What are database links used for?

994


How many types of index are there?

962


Is sql between inclusive?

1063


What is a natural join sql?

922


What does data normalization mean?

900


What does (+) mean in sql joins?

1012