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

how to increment dates by 1 in mysql? : Sql dba

978


What is a natural join?

1074


What is type and rowtype in pl sql?

1017


Why coalesce is used in sql?

1012


How do I send sql query results to excel?

1066


how do you tune the slow running queries in oracle db , explain the methodology

2799


Is natural join and inner join same?

928


Can a procedure in a package be overloaded?

1045


How does sql*loader handles newline characters in a record? : aql loader

1046


How can one get sql*loader to commit only at the end of the load file? : aql loader

1059


What is the mutating table and constraining table?

1026


What is nvl?

1065


Can we join two tables without common column?

1005


What are the most important ddl statements in sql?

1116


How can I speed up sql query?

963