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
Please get the 4 th maximum salary from a table without 
using any sql keyword (TOP,MAX are mot allowed)
 Question Submitted By :: Ayanb1302@yahoo.com
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Please get the 4 th maximum salary from a table without using any sql keyword (TOP,MAX are mot allowed)
Answer
# 1
DECLARE @test TABLE(Empnm VARCHAR(10), Salary VARCHAR(10))

INSERT INTO @test (Empnm, Salary ) 
SELECT 'A', '200'
UNION ALL 
SELECT 'B', '300'
UNION ALL 
SELECT 'A', '200'
UNION ALL 
SELECT 'B', '300'
UNION ALL 
SELECT 'C', '400'
UNION ALL 
SELECT 'C', '400'
UNION ALL 
SELECT 'E', '100'
UNION ALL 
SELECT 'D', '500'

SELECT * FROM @test 


SELECT Empnm, Salary, (SELECT COUNT(DISTINCT(SALARY)) FROM
@test AS B WHERE A.Salary <= B.SALARY) 
FROM   @test AS A
GROUP BY Empnm, Salary 
HAVING 4 = (SELECT COUNT(DISTINCT(SALARY)) FROM @test AS B
WHERE A.Salary <= B.SALARY)
 
Is This Answer Correct ?    1 Yes 1 No
Pradeep
 
  Re: Please get the 4 th maximum salary from a table without using any sql keyword (TOP,MAX are mot allowed)
Answer
# 2
Create Table 'Employee' with columns 'Emp_Name' 
and 'Salary'. And, Insert some data.....

Cursor:
declare Cursor_Name cursor scroll
for select salary from Emploee order by salary desc
open Cursor_Name
fetch absolute 2 from Cursor_Name
deallocate Cursor_Name
 
Is This Answer Correct ?    0 Yes 0 No
Sumathy
 
 
 
  Re: Please get the 4 th maximum salary from a table without using any sql keyword (TOP,MAX are mot allowed)
Answer
# 3
Am Sumathy the above answer was posted by me.

For the above Answer 'absolute 2' will fetch 2nd maximum 
value.

To fetch 4th maximum value use 'absolute 4'
To fetch 'n'th maximum value use 'absolute n'
 
Is This Answer Correct ?    0 Yes 0 No
Sumathy
 
  Re: Please get the 4 th maximum salary from a table without using any sql keyword (TOP,MAX are mot allowed)
Answer
# 4
select payout,emp_cd from empmas e where 2>(select count(payout) from empmas s where s.payout>e.payout);
 
Is This Answer Correct ?    0 Yes 0 No
Suresh
 
  Re: Please get the 4 th maximum salary from a table without using any sql keyword (TOP,MAX are mot allowed)
Answer
# 5
select * from (select *,row_number()over (order by salary
asc)as a from Employee)as b where b.a=4
 
Is This Answer Correct ?    0 Yes 0 No
Gajendra
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
HOW TO FIND THE EMPLOYEE DETAILS WHO ARE GETTING SAME SALARY IN EMP TABLE TCS16
CREATE TABLE [dbo].[HPMS_CompetencyTypes](CompetencyType varchar(50) ) go create trigger hpms_create_Insert on HPMS_CompetencyTypes for insert as if Exists ( select * from [HPMS_CompetencyTypes] where CompetencyType=(select * from [HPMS_CompetencyTypes])) begin Rollback tran Raiserror ('duplicate value',12,6) go insert HPMS_CompetencyTypes (CompetencyType) values ('new') I'm new to trigger can any one tell me where is the issue. Please.  2
Name three version of sql server 2000 and also their differences?  1
What is row by row processing ?  1
About types of indexes in SQL server ? Cognizent1
what is the query and condition to delete datas in sql server.  2
what is the signification difference of this bit data type between sql 6.5 and later version sql server?  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
What are the advantages of using stored procedures? Please don't simply say compilation time will be saved as they are already complied. Please specify some other advantages. 247Customer3
How to work on DTS?what is the main requirement? ivan1
In performance wise distinct is good or group by is good? eg:select name from emp group by name; select distinct name from emp; Infosys4
How do you check the performance of a query and how do you optimize it?  1
logshipping is Any difference 2000 and 2005?  1
What is difference beteen Migration and Upgrdation? Satyam4
What all db objects can be found in MSDB database of a SQL Server instance? Accenture1
What is Trigger? Misys2
hi, may i know what is the command to get abstract the current month, current year and current day from a given date.i want these three in a isolated way..seperatedly is that any way in sql server 2000  3
in emptable i want to retrive the name of employee whose name in 'J'char.exp: arjun,jagadesh,niranjan,anju,aaaj etc.  7
Which is best Subquery (or) joins in sql server? explain why  2
How can I know what query is executing by by a particural user? (using sp id or any othe way.)  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