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                      
tip   To Refer this Site to Your Friends   Click 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
from the table display the 2nd highest salary?
and also the least 2nd salay?

 Question Submitted By :: Om Namo Bhagavathe Vasudevaya
I also faced this Question!!     Rank Answer Posted By  
 
  Re: from the table display the 2nd highest salary? and also the least 2nd salay?
Answer
# 1
SELECT 'Second Highest Salary Is ', MAX(Salary) FROM Employee WHere Salary < ( Select MAX(Salary) FROM Employee )

SELECT 'Second Least Salary Is ',MIN(Salary) FROM Employee  WHere Salary > ( Select MIN(Salary) FROM Employee )
 
Is This Answer Correct ?    3 Yes 2 No
Soorai Ganesh
 
  Re: from the table display the 2nd highest salary? and also the least 2nd salay?
Answer
# 2
2nd Highest Salary

Select top 1  salary from (select distinct top 2 salary 
from employee order by salary desc)a
order by salary

2nd Least Salary

Select top 1  salary from (select distinct top 2 salary 
from employee order by salary asc)a
order by salary desc
 
Is This Answer Correct ?    2 Yes 2 No
Smitha
 
 
 
  Re: from the table display the 2nd highest salary? and also the least 2nd salay?
Answer
# 3
select p.emp_id,p.name,p.salary from
(select emp_id,name,salary,dense_rank()over( order by 
salary desc)maxrank,
dense_rank()over( order by salary asc)minrank from test)p
where maxrank=2 or minrank=2
 
Is This Answer Correct ?    1 Yes 0 No
Bobby
 
  Re: from the table display the 2nd highest salary? and also the least 2nd salay?
Answer
# 4
for 2nd highest salary

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


for 2nd least salary

select min(salary) from employee where salary>(select min
(salary) from employee )

i hope that will help you
 
Is This Answer Correct ?    0 Yes 0 No
Mehul
 
  Re: from the table display the 2nd highest salary? and also the least 2nd salay?
Answer
# 5
select distinct top 1 salary from payroll..emp where salary 
in(select distinct top 3 salary from payroll..emp order by 
salary desc)
 
Is This Answer Correct ?    1 Yes 0 No
Sridhar Sahoo
 
  Re: from the table display the 2nd highest salary? and also the least 2nd salay?
Answer
# 6
select distinct top 1 salary from payroll..emp where salary 
in(select distinct top N salary from payroll..emp order by 
salary desc)

if u want top 2 put 2 at the pacece of N
if u want top 5 put 5 at the pacece of N
if u want ..............................
 
Is This Answer Correct ?    0 Yes 0 No
Sridhar Sahoo
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
What are the authentication modes in SQL Server?  2
1.can we set the more than 1 primary keys for a table? 2.please give me the difference between Cluster Index and non-Clustered Index 3.can we use query like this "Select * from Table1,Table2;"  6
What are the new features in SQL Server 2005? Emphasis2
Wht is SQL Injection Attack ?  1
in emptable i want to retrive the name of employee whose name in 'J'char.exp: arjun,jagadesh,niranjan,anju,aaaj etc.  7
What meant by Performance Tuning,how can we do the performance tuning on stored procedures and tell some steps to do the performance tuning TCS1
Can you explain the role of each service?  1
What is the difference between temp table and table variable? Microsoft4
How to Check Whether a Global Temporary Exists in a SQL Database or not?  2
how to replace double quotes by single quotes in sql server CAC2
What is the difference between OLEDB and ODBC CFCI3
how to give input dynamically to a insert statement in sqlserver HCL2
what is the output for this query select * from employee where 1=1;  4
Is it possible to allow NULL values in foreign key? I s it possible to use different constraints for the same column in the table (i.e) (id int NOT NULL,UNIQUEUE)  1
to explain sql server 2000 architecture & authentication  1
How to write query to Delete the records in child table and corresponding records in parent table Semantic-Space8
How to Execute an Operating System Command From Within SQL Server ?  2
what is Constraint? How many types of constraints in SQL ? NIIT7
i have a table student like sname ----- ram ram ram raj raj raj i need the output like sname ----- ram raj ram raj ram raj IBM7
How do you implement one-to-one, one-to-many and many-to- many relationships while designing tables? TCS3
 
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