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       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
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
select the 3rd maximum salary from sql server database if 4
(just an example In practically I may not know the exact 
situation) of the highest salaries are equal.
 Question Submitted By :: Shekhar
I also faced this Question!!     Rank Answer Posted By  
 
  Re: select the 3rd maximum salary from sql server database if 4 (just an example In practically I may not know the exact situation) of the highest salaries are equal.
Answer
# 1
SELECT TOP 1 salary 
FROM (
SELECT DISTINCT TOP 3 salary 
FROM tblSalary
ORDER BY salary DESC) S 
ORDER BY salary
 
Is This Answer Correct ?    15 Yes 3 No
Shekhar
 
  Re: select the 3rd maximum salary from sql server database if 4 (just an example In practically I may not know the exact situation) of the highest salaries are equal.
Answer
# 2
SELECT EmpID,Salary from tblSalary a where 3=(select count
(EmpID) from tblSalary b where b.empid=a.empid)

for any RDBMS
 
Is This Answer Correct ?    1 Yes 8 No
Sunil Nair
 
 
 
  Re: select the 3rd maximum salary from sql server database if 4 (just an example In practically I may not know the exact situation) of the highest salaries are equal.
Answer
# 3
SELECT EmpID,Salary from tblSalary a where 3=(select count
(distinct EmpID) from tblSalary b where b.empid>=a.empid)

For any database
 
Is This Answer Correct ?    1 Yes 2 No
Sunil Nair
 
  Re: select the 3rd maximum salary from sql server database if 4 (just an example In practically I may not know the exact situation) of the highest salaries are equal.
Answer
# 4
select empid,salary
from (select distinct empid,salary,
Dense_Rank() over(order by salary desc) as Rank
from dbo.EmpSalary) b
where b.rank=3
 
Is This Answer Correct ?    1 Yes 1 No
Kiran
 
  Re: select the 3rd maximum salary from sql server database if 4 (just an example In practically I may not know the exact situation) of the highest salaries are equal.
Answer
# 5
CREATE procedure Proc_Loaddata_Text (@File_path nvarchar
(255),@Table_Name varchar(100)) AS
   
DECLARE @SQLString NVARCHAR(4000)

/* Build Command*/

SET @SQLString =N'Bulk Insert ['+@Table_Name+'] from ' + 
N'N''' + @File_path + N''' with (FIELDTERMINATOR=''|'', 
ROWTERMINATOR = ''\n'')'

--print @SQLString

/* Execute */

EXEC (@SQLString)
GO
 
Is This Answer Correct ?    0 Yes 1 No
Sandeep Saxena
 
  Re: select the 3rd maximum salary from sql server database if 4 (just an example In practically I may not know the exact situation) of the highest salaries are equal.
Answer
# 6
SELECT TOP 1 salary 
FROM (
SELECT DISTINCT TOP 3 salary 
FROM tblSalary
ORDER BY salary DESC)
 
Is This Answer Correct ?    0 Yes 0 No
Vijay Saxena
 
  Re: select the 3rd maximum salary from sql server database if 4 (just an example In practically I may not know the exact situation) of the highest salaries are equal.
Answer
# 7
--Sumesh.S.G--
SELECT TOP 1 salary 
FROM (select top 3 Salary
from dbo.TBL_Employee
order by Salary desc) as TemTable order by Salary asc
--Happy coding--
 
Is This Answer Correct ?    1 Yes 0 No
Sumesh.s.g
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
How do we return a record set from a Stored Procedure in SQl server 2000?  2
can primery key be a non clustered index?  8
please can anyone answer this query Table 1 has 2 columns: EmployeeId,Age Table 2 has 2 columns: EmployeeId, Region Write SQL to Find the region who has the oldest person  7
i want to join two queries....and i want to run them as one after another that is want output of first query then second , then again output of first query then second and so on...  2
wat will be the sql query to extract only last 3 records from table supose table hving thousands for records  16
What is the difference between a Local temporary table and a Global temporary table? How is each one used?  1
I have student marks in a student table. I need second highest mark .Then what will the query for this? Wipro23
What is the difference between a local and a global variable?  3
hi i gone though satyam interview. what is Acid Properties? Satyam2
What is a materialized view?  2
how to select 5 to 7 rows from a table, which contains 10 rows? IBM14
CLR Integration ? what is Notification services ? Satyam1
What are cursors? Name four types of cursors and when each one would be applied? Adea-Solutions1
What is the difference between Userdefined function and stored procedure? Explain and give the example also  4
what are file groups? Evalueserve3
Which institute is best for SQL Server 2005 Training?  5
how can i view structure of table in sql server? tell me that query.  4
What's the difference between a primary key and a unique key? Wipro8
What is a trigger?  3
what is difference between having and where clause ?  2
 
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