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

Can we perform dml in function?

1135


What is a temp table?

1074


What do you mean by table in sql?

1045


what are the different tables present in mysql? : Sql dba

1046


how to include comments in sql statements? : Sql dba

999


discuss about myisam key cache. : Sql dba

1072


List the ways to get the count of records in a table?

943


What does subquery mean in sql?

1114


Why do we use function in pl sql?

1114


How do I view a table in sql?

1043


What are triggers and its types?

1120


How do you declare a constant?

1018


define sql delete statement ? : Sql dba

1069


Should I use mbr or gpt?

1063


What is restrict in sql?

1179