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 many commands are in sql?

1066


What is percent sign in sql?

1281


Can a trigger call a stored procedure?

1064


What are primary key and foreign key and how they work?

973


What is an example of translating a date into julian format?

1115


What is on delete restrict?

998


What is a sql*loader control file?

1256


Is keyword pl sql?

983


how do you login to mysql using unix shell? : Sql dba

1077


What is the file extension for sql database?

997


Mention what does plvtab enables you to do when you showthe contents of pl/sql tables?

1162


Do stored procedures prevent sql injection?

966


How does index help in query performance?

1025


what are the difference between clustered and a non-clustered index? : Sql dba

1030


how to delete duplicate rows from a join tables(I have three tables on that join) how do you know which join is need to be used? The select statement I have is: SELECT gc_skill_type.skill_type, gc_area_tec.area, gc_technology.technology, gc_technology.id_technology, gc_area_tec.id_area_tec FROM gc_skill_type, gc_area_tec, gc_technology WHERE gc_area_tec.id_skill_type (+) = gc_skill_type.id_skill_type AND gc_technology.id_area_tec (+) = gc_area_tec.id_area_tec order by gc_skill_type.skill_type asc, gc_area_tec.area asc, gc_technology.technology asc

4011