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

Which is better trigger or stored procedure?

1016


What is data control language?

1034


What is trigger and types?

1071


Is it mandatory for the primary key to be given a value when a new record is inserted?

1254


How do I tune a sql query?

1043


What is trigger price?

1049


how to convert numeric values to character strings? : Sql dba

1162


What is the sql query to display the current date?

1094


What are all different types of collation sensitivity?

1077


Can a table contain multiple foreign key’s?

1056


How many parts of a pl sql block are optional?

1219


What is not equal in sql?

1196


how can we find the number of rows in a table using mysql? : Sql dba

1130


what are the differences among rownum, rank and dense_rank? : Sql dba

1087


What is the most common sql injection tool?

1091