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?

Answers were Sorted based on User's Feedback



how to find the second highest salary from emp table?..

Answer / naveed saleh

You can use this for getting nth highest salary from
Employee table as follows

SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP n salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary
where n > 1 (n is always greater than one)

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / anantkreshna v

select max(sal) from emp_table where sal < (select max(sal)
from emp_table);

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / mona thakur

SELECT *
FROM emp
WHERE salary < (
SELECT max( salary )
FROM emp )
ORDER BY salary DESC
LIMIT 1

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / kishor

select max(salary ) from employee
where
sal<(select max(salary)from employee)

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / vijay shegokar

select * from employee where salary=(select max(salary) from
employee where salary not in (select max(salary) from
employee));

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / vijay kintali

select e1.ename,e1.sal from emp e1 where n=(select count
(distinct e2.sal) from emp e2 where e1.sal<=e2.sal);

Note:n here is nth highest salary.......

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / arvind

select max(salary) from table_name where sal<(select
max(salary) from table_name)

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / bharat puri

select top 2 (salary) from emp
order by salary desc

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / gurvinder

select max(sal)from emp where sal in(select sal from emp minus select max(sal) from emp);

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / sankar sasmal

select distinct sal from emp e where 2=(select count(distinct sal)from emp s where e.sal<=s.sal)

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

How can you tell the difference between an index and a view?

0 Answers  


wt is the diff b/w greast and max ,least and min? wt is the diff b/w case and decod?

4 Answers   Oracle, TCS, Tecnics,


How does sql store data?

0 Answers  


How do I know if I have sql express or standard?

0 Answers  


What is sql and also describe types of sql statements?

0 Answers  


How many sql core licenses do I need?

0 Answers  


How to add, remove, modify users using sql?

0 Answers  


How can get second highest salary in sql?

0 Answers  


what is the difference between varray and table data type..please expalain with some examples... under what situation you will go for varray..instead of index by table...

1 Answers   HCL, Satyam,


Is sql open source?

0 Answers  


Which one of the following is a reason that an INSERT statement might cause an error instead of executing correctly? 1. The INSERT statement was attempting to insert a record into a view that was created from more than one table. 2. The INSERT statement was attempting to insert a record using a combination of constants and values from an existing table. 3. The INSERT statement was attempting to insert a record with a non-NULL value into a table that has that column defined as NULL. 4. The INSERT statement was attempting to insert a record into a table by selecting a record from that same table. 5. The INSERT statement was attempting to insert a record into a view rather than a table.

1 Answers   Sonata,


Does postgresql run on the cloud?

0 Answers  


Categories