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
 
How To Make password Protected SQL Server 2005 Database i.e when i open SQL Server database then ask for password.  1
what is the Enterprise manager(2000) and management studio (2005)?  2
employee table has employee id ----------- empid ---------------- 1 2 3 3 3 4 5 5 5 6 6 6 7 here the values r repeated two times.how to select the repeated values only.i.e 3,5,6 should alone come.  2
how to delete duplicate rows from table CSC9
What is normalization in Database ?  4
What is the system function to get the current user's user id? TCS3
What is the default value of CHAR type? Bosch8
We create an index to fast the search. How it fast the query? Do we write any special keyword with query?  3
What are the four main query statements?  3
I have a table in which phno is one of the columns.i do have some values in tht phno column.i need to update phno column values with 0(zero) as prefix.give me a correct solution plz... Value-Labs5
Please tell me some knowledge about Clustering and how to add clustering?  1
How do you use DBCC statements to monitor various aspects of a SQL server installation?  1
1.what is the purpose of using alias name in sql server? with certain example? 2.what is cursor?will u plz explain me in detail with certain example?  3
how many joins we can write if at all we have n no of tables Tanla-Solutions4
How to give a user the option of importing Excel and a delimited text file into a SQL Server Database without manually using SQL DTS? GE1
Can we use Truncate command on a table which is referenced by FOREIGN KEY?  2
9. Write a query to list a new column with the difference in temp of the cities Delhi and Mumbai, Mumbai and Jammu and soon. Consider the following table : City_id City Temp. 1 delhi 40 2 Mumbai 35 3 Jammu 32 4 Pune 18  2
can any one please send sql quries most used in applications.  1
What are the differences between stored procedure and functions in SQL Server 2000? TCS12
we have emp table like Ename,EDOJ,EDOB with Column structure.but we want to know the employee Age.How? Any Body Plz  6
 
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