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 retrieve a second highest salary from a table?
Note:Suppose salaries are in duplicate values
eg:
Name Sal
Malli 60000
Pandi 60000
Rudra 45000
Ravi 45000

Answer Posted / praveenpinfo

Suppose table name is EMP.

SQL> Select distinct sal from emp e1 where 2=(select
count(distinct sal) from emp e2 where e1.sal<=e2.sal);

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are sql triggers used for?

991


Is it possible to pass parameters to triggers?

1099


explain the options of myisamchk to improve the performance of a table. : Sql dba

1006


What is flag in sql?

1028


How do you write a subquery?

1023


Why we use cross join?

950


Explain the difference between drop and truncate commands in sql?

1042


What is sqlcontext?

1074


Can 2 queries be executed simultaneously in a distributed database system?

1140


What is t sql in sql server?

1066


What does desc stand for?

1065


What is query syntax?

961


Can we use rowid as primary key?

982


explain access control lists. : Sql dba

995


Do triggers have restrictions on the usage of large datatypes, such as long and long raw?

1161