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 / ashish damohiya

Answer :
Select max(salary) from Emp_Table where max(salary) not in
(Select max(Salary) from Emp_Table)
this sufficient answer.

but there change the format of question that
How to find the second highest salary of each employee form
emp table ?

Answer :

with cte as (
select rank() over(order by emp_name) rank1 , ROW_NUMBER()
OVER(partition by emp_name ORDER BY basic desc) row,
emp_name, basic from emp_master)
select * from cte where row =2 or rank1 in ( select rank1
from cte group by rank1 having count(rank1)=1)

there i am used the MS SQL Server 2005.

Is This Answer Correct ?    0 Yes 0 No

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

Answer / chaitanya pathak

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

Is This Answer Correct ?    0 Yes 0 No

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

Answer / bharath reddy

These qeries give you second higest salary

select e.sal from emp e,emp d where d.sal>e.sal
group by e.sal
having count(e.sal)=2
;

SAL
-----
3000

(or)

select distinct e.sal from emp e where (select count(sal)
from emp d where d.sal>e.sal)=1;

SAL
-----
3000

Is This Answer Correct ?    0 Yes 0 No

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

Answer / teja

select max(sal) from emp where empsal<(selelect max(sal)
from emp)

Is This Answer Correct ?    0 Yes 0 No

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

Answer / anandaraj

This below query is used to get the name and salary of
second highest salary person. Its work great.

select Name, Salary from table_3 where salary = (select max
(salary) from table_3 where salary < (select max(salary)
from table_3 )).

Is This Answer Correct ?    0 Yes 0 No

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

Answer / raju

select top 1 sal from emp
where sal not in (select top 1 sal from emp order by sal
desc ) order by sal desc

Is This Answer Correct ?    0 Yes 0 No

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

Answer / jigar r gor

Select sal from emp where sal < (select max(sal)from emp)
and rownum < 2 order by sal desc

Is This Answer Correct ?    0 Yes 0 No

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

Answer / sagar padekar

select * from bill_gen
where total_payable< (select max(total_payable) from
bill_gen) order by total_payable desc limit 1;

hey please refer total_payable as salary amount

Is This Answer Correct ?    0 Yes 0 No

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

Answer / shiva

select salary from table_name where salary <(select salary
from table_name);

Is This Answer Correct ?    0 Yes 0 No

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

Answer / yash goyal

Select slary from
(select salary from empolyees
order by salary desc
where rownum<=&no.)
order by salary Asc
where rownum=1;

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

What are the string functions in sql?

0 Answers  


What is the use of prepared statement?

0 Answers  


What is the difference between unique and primary key constraints?

0 Answers  


What are the various levels of constraints?

0 Answers  


Does execute immediate commit?

0 Answers  


How to display Row Number with Records in Oracle SQL Plus?

0 Answers   MCN Solutions,


What is the difference between pl and sql?

0 Answers  


How would you reference column values before and after you have inserted and deleted triggers?

0 Answers  


can i call procedure in package

3 Answers   TCS,


What is java sql driver?

0 Answers  


What are system versioned tables?

0 Answers  


what are the differences between procedure-oriented languages and object-oriented languages? : Sql dba

0 Answers  


Categories