|
|
NEW INTERVIEW QUESTIONS.COM
DATABASE INTERVIEW QUESTIONS
SQL INTERVIEW QUESTIONS DETAILS
NewInterviewQuestions.com - Home for World's Largest Interview Questions Website.
A D V E R T I S E M E N T
Question |
How Find Second highest salery from database |
Answer
|
select min() from where in(select top 2 from order by desc)
Answered By: Sachi Date: 2/4/2008
select min(salary) from
where salary in(select top 2 salary from order by salary desc)
Answered By: Sachi Date: 2/4/2008
--2nd highest salary--
SELECT * FROM Emp WHERE (Salary = (SELECT MAX(Salary) FROM Emp WHERE
(Salary NOT IN (SELECT TOP (1) Salary FROM Emp ORDER BY Salary DESC))))
Answered By: Ritesh Nagpal Date: 2/15/2008
select e1.*
from employees e1
where 1=
( select count(distnct e2,sal)
from employees e2
where e2 sal
Answered By: jasu Date: 3/8/2008
select min(Salary) from Employee where Salary in (select top 2(Salary)
from Employee order by Salary asc)
Answered By: Amit Krishnan Date: 3/10/2008
select min(salary) from(select top 2 salary from tablename order by salary desc)A
U can find any rank by changing the value in the top n(for 5 th rank give top 5)
Answered By: AMJEMS NETTO Date: 3/10/2008
select top 1 salary from emp
where salary<(Select max(salary) from emp)
Answered By: Janakiraman.N Date: 3/13/2008
"Answer to Q. No. 11985"
SELECT DISTINCT salary FROM employee a WHERE 2=(select COUNT(DISTINCT salary) FROM employee b WHERE a.salary<=b.salary)
Answered By: Sangeetha Ramasamy Date: 3/18/2008
select max( sal )
from db
where sal not in
( select max( sal )
from db )
Answered By: Sourav Pal Date: 5/12/2008
select top 1 from (
(
select top 2 from
(select salary,employeeid from employee order by salary desc) as top2) as seconhighest) order by 1 asc
Answered By: praveen Date: 5/17/2008
select top 1 salary from (select top 2 salary from empsalary order by salary desc)as temptable order by asc
Answered By: subbu Date: 5/22/2008
© NewInterviewQuestions.com
If you have the better answer, than send it to us. We will display your answer after the approval.
Rate the above answer. Help us to know about the answer.
Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.
|
Newinterviewquestions.com is a part of
Vyom Network.
Page URL:
http://www.newinterviewquestions.com/interview/11985/Default.asp?cachecommand=bypass
Download Yahoo Messenger
|
Web Hosting |
Dedicated Server |
Free SMS
| | |