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 / kishan singh chilwal

SELECT MAX(sal)
FROM emp
WHERE sal <> (SELECT MAX(sal) FROM emp);

<> = not equal to
the SELECT statement in the WHERE clause will find the 1st max sal in the table
the 1st SELECT statement will find max sal in the table after excluding the first max sal

(ALTERNATE WAY)

SELECT MAX(sal)
FROM emp
WHERE sal not in (select max(sal) from emp );

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is user defined functions?

915


Explain the difference between drop and truncate commands in sql?

962


Does pdo prevent sql injection?

884


How to use sql statements in pl/sql?

1053


How do you write a complex sql query?

1007


what is a materialized view? : Sql dba

996


what are the differences between get and post methods in form submitting. Give the case where we can use get and we can use post methods? : Sql dba

1084


how do you know the version of your mysql server? : Sql dba

936


Explain what is a subquery ?

1122


What is compiled query?

954


what are the authentication modes in sql server? : Sql dba

998


List and explain the different types of join clauses supported in ansi-standard sql?

1300


How many aggregate functions are available there in sql?

929


What is coalesce sql?

940


Is sql open source?

915