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 / vikas naik

select max(sal) from employee where sal not in(select
max(sal) from employee);

Is This Answer Correct ?    3 Yes 1 No

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

Answer / chitti

Hi Viewers here is the simple query to find the highest
salary:-

1)Highest five salaries:-

select top 5 salary from employee order by salary desc

2)Highest 5th salary:-

select top 1 salary from(select top 5 salary from
employee order by salary desc) temp1 order by salary asc

3)Highest 4th salary:-

select top 1 salary from (select top 4 salary from
employee order by salary desc) temp1 order by salary asc

4)Highest 3rd salary:-

select top 1 salary from (select top 3 salary from
employee order by salary desc) temp1 order by salary asc

5)Highest 2nd salary:-

select top 1 salary from(select top 2 salary from
employee order by salary desc) temp1 order by salary asc

6)Highest 1st salary or highest salary:-

select max(salary) from employee

Is This Answer Correct ?    2 Yes 0 No

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

Answer / abhishek kundu

SELECT MAX(SALARY) FROM EMP
WHERE SALARY<(SELECT MAX(SALARY) FROM EXP);

Is This Answer Correct ?    2 Yes 0 No

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

Answer / chirag shah

select DISTINCT(salary) from emp order by salary desc limit 1,1

this limit gives you 2nd record
if you want 3rd value then write limit 3,1

Is This Answer Correct ?    2 Yes 0 No

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

Answer / prudhvi

select sal from emp a where 1=(select count(*) from emp b where a.sal>b.sal);

Try this guys,if u want highest sal use 0 in where condition, for second highest 1,third 2........

Is This Answer Correct ?    2 Yes 0 No

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

Answer / jithu

SELECT MAX(SALARY) FROM EMPLOYEE WHERE SALARY NOT IN
(SELECT MAX(SALARY) FROM EMPLOYEE)

Is This Answer Correct ?    9 Yes 8 No

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

Answer / subash pandey

SELECT salary
FROM employee e
WHERE n = (
SELECT count( * )
FROM employee
WHERE salary > e.salary )

n=1 or 2 or 3 n is level which level max salary you want
i test this it proper work

Is This Answer Correct ?    4 Yes 3 No

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

Answer / aravind naidu

select * from emp e where (select count(*) from emp where sal>=e.sal)=&n; put n = 2 for second highest sal,n = 3 for third highest sal ....and so on.

Is This Answer Correct ?    2 Yes 1 No

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

Answer / raju tt

select max(salary) from employees where salary not in
(select max(salary) from employees)

Is This Answer Correct ?    1 Yes 0 No

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

Answer / barochia dharmesh

select Income from (
select Rank() over(order by Income desc) topRecord, Income
from (select distinct Income from tblName) tbl ) tbl2
where topRecord = 2

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

How do I create a memory optimized filegroup?

0 Answers  


Can you have multiple SPs with the same name on a database?

6 Answers   CGI,


Explain two virtual tables available at the time of database trigger execution.

1 Answers  


What is the clause we need to add in function body to return variable?

0 Answers  


What is pls integer?

0 Answers  


How is indexing done in search engines?

0 Answers  


Explain isolation levels. : Transact sql

0 Answers  


Hello All, Could any well write a query for the following scenario. Account(table name) No Name Amount 1 ABCD 2000.00 2 DEFG -2000.00 3 GHIJ 3000.50 4 JKLM 4000.00 5 MNOP 6000.00 O/p Should be in this format No Name Credit Debit 1 ABCD 2000.00 0 2 DEFG 0 -2000.00 3 GHIJ 3000.50 4 JKLM 0 -4000.00 5 MNOP 6000.00 o could any one give appropriate query for this Thnks in Advance Suneel Reddy

6 Answers   Target,


What is synchronized subquery?

0 Answers  


Does truncate need commit?

0 Answers  


What does fetching a cursor do?

0 Answers  


while loading data into database how can u skip header and footer records in sql*loader

1 Answers   Oracle,


Categories