ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Databases  >>  SQL Server
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
please tell me the query to get details of the employee 
having the second largest salary
 Question Submitted By :: Srikanth
I also faced this Question!!     Rank Answer Posted By  
 
  Re: please tell me the query to get details of the employee having the second largest salary
Answer
# 1
select min(a.standardcost) from 
(
select distinct top 2  StandardCost
from Production.ProductCostHistory
order by standardcost desc
)a
 
Is This Answer Correct ?    2 Yes 0 No
Sushil
 
  Re: please tell me the query to get details of the employee having the second largest salary
Answer
# 2
SELECT * FROM Emp e1
WHERE 2 = (SELECT COUNT(*) FROM Emp e2 WHERE e1.Salary <= 
e2.Salary)
 
Is This Answer Correct ?    3 Yes 2 No
Krishna Mohan Thamisetty
 
 
 
  Re: please tell me the query to get details of the employee having the second largest salary
Answer
# 3
select top 2(salary) from emp_sal where
salary in (select sal from emp_sal order by sal desc)
 
Is This Answer Correct ?    2 Yes 2 No
Ravikiran
 
  Re: please tell me the query to get details of the employee having the second largest salary
Answer
# 4
Select * from EmpTbl Where Salary = (Select Max(Salary) from
EmpTbl Where Salary < (Select Max(Salary) from EmpTbl)
 
Is This Answer Correct ?    1 Yes 1 No
Devendra Dwivedi
 
  Re: please tell me the query to get details of the employee having the second largest salary
Answer
# 5
Select max(Salary) from employeetable where salary < (select
max(salary) from Employeetable)
 
Is This Answer Correct ?    4 Yes 0 No
Shivangi
 
  Re: please tell me the query to get details of the employee having the second largest salary
Answer
# 6
select max(salary) from emp 
where salary<(select max(salary) from emp)
 
Is This Answer Correct ?    1 Yes 0 No
Eswar
 
  Re: please tell me the query to get details of the employee having the second largest salary
Answer
# 7
select  employeeid, employeeName ,Salary  from table1 where 
Salary =(select min(a.Salary) from table1 inner join 
(select top 2 Salary from table1 
order by Salary desc) a on table1.Salary = a.Salary)

if we change the top value we will get the n'th largest 
salary
 
Is This Answer Correct ?    0 Yes 0 No
Roshan
 
  Re: please tell me the query to get details of the employee having the second largest salary
Answer
# 8
If we had a table named Employee which had a column named 
Salary and we had to find the second highest Salary in the 
Employee table, the query for the same would be:

SELECT TOP 1 Salary FROM (SELECT TOP 2 Salary FROM Employee 
ORDER BY Salary DESC) AS E ORDER BY Salary ASC

The subquery or the inner query would return the top 2 rows 
in descending Salary order which would be:
5000
4000
The outer query would then select the top 1 row from the 
subquery results in ascending Salary order which would be:
4000
 
Is This Answer Correct ?    0 Yes 0 No
Rathi
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
can any one answer this query,thank you in advance Table 1 has 2 columns: EmployeeId, T shirtsize(values can be 1,2,3) Table 2 has 2 columns: EmployeeId, Region Write SQL to Find the region which has the largest number of people with Tshirt size=3 Google10
What is lock escalation?  1
Wht is SQL Injection Attack ?  1
Different Types of Functions ? Satyam2
What is the default value of CHAR type? Bosch8
How to write a script for upate the data in prod , i have 50000 row are there TCS2
What is the appropriate number of test cases that you can write on a database? Microsoft1
Lets say due to N/W or Security issues client is not able to connect to server or vice versa. How do you troubleshoot?  1
What are constraints? Explain different types of constraints?  6
write the query for taking database restore in sql?  2
What is one of the first things you would do to increase performance of a query? For example, a boss tells you that ?a query that ran yesterday took 30 seconds, but today it takes 6 minutes? Wipro1
how to write the query to select the rows are in the order of either 1,3,5,7... or 2,4,6,8,... ADP5
Explain fundamentals of Data ware housing & OLAP?  1
what is the importence of the trigger in sqlserver2000? ATI1
What is a sub-query? When would you use one?  3
How would you Update the rows which are divisible by 10, given a set of numbers in column?  1
What types of integrity are enforced by a foreign-key constraint  1
explain different types of jions with examples briefly? Zensar2
Which databases are part of SQL server default installation? Explain the usage of each? Accenture2
About types of indexes in SQL server ? Cognizent1
 
For more SQL Server Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com