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

select * from (select sal,deptno from emp a where
sal in (select distinct(b.sal) from emp b
where a.deptno=b.deptno and rownum<4)
order by deptno,sal desc )
minus
select * from (select sal,deptno from emp a where
sal in (select distinct(b.sal) from emp b
where a.deptno=b.deptno and rownum<3)
order by deptno,sal desc )

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I trace sql profiler?

970


How do you create a unique index?

1045


what are all the different normalizations? : Sql dba

1036


What are the benefits of stored procedures?

1060


Explain the working of primary key?

1092


What is the difference between rename and alias?

1341


How much ram can sql express use?

982


what are properties of a transaction? : Sql dba

1092


What is string data type in sql?

1137


What is the difference between null value, zero, and blank space?

1199


What are records give examples?

1001


what is a database lock ? : Sql dba

1164


How do I find duplicates in two columns?

1162


what is rollback? : Sql dba

1104


How can you fetch first 5 characters of the string?

1015