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
how do we find every fifth record in a table
 Question Submitted By :: Waqar
I also faced this Question!!     Rank Answer Posted By  
 
  Re: how do we find every fifth record in a table
Answer
# 1
SELECT RowNumber from ( Select ROW_NUMBER() OVER (order by 
EmployeeID)as RowNumber
  FROM Employee)  as x 
where x.RowNumber % 5 = 0
 
Is This Answer Correct ?    5 Yes 3 No
KrishanS
 
  Re: how do we find every fifth record in a table
Answer
# 2
select * from employee where employeeID % 5=0
 
Is This Answer Correct ?    2 Yes 5 No
Vijaya
 
 
 
  Re: how do we find every fifth record in a table
Answer
# 3
Select Top 1 * From (Select Top 5 * From Employee Order By 
1 Asc) As X Order By 1 Desc
 
Is This Answer Correct ?    6 Yes 1 No
Jahir
 
  Re: how do we find every fifth record in a table
Answer
# 4
select salary from emp e where 4=(select count(salary) from 
emp where salary>e.salary
 
Is This Answer Correct ?    0 Yes 2 No
Satya Gupt
 
  Re: how do we find every fifth record in a table
Answer
# 5
Using Top N analysis....


select * from (select  rownum rn, col1,col2,col3 from 
tablename) where mod(rn,5)=0;
 
Is This Answer Correct ?    0 Yes 3 No
Santhi K
 
  Re: how do we find every fifth record in a table
Answer
# 6
Table Name Is Employee 
EmployeeId Is Identity field 

Select * From Employee Where EmployeeId In (Select 
EmployeeId From Employee Where EmployeeId%5=0)

by
Kumar.T
 
Is This Answer Correct ?    1 Yes 2 No
Kumar.t
 
  Re: how do we find every fifth record in a table
Answer
# 7
Select Top 1 * From (Select Top 5 * From customers Order By 
1 Asc) X Order By 1 Desc
 
Is This Answer Correct ?    3 Yes 2 No
Srivatsa P
 
  Re: how do we find every fifth record in a table
Answer
# 8
select * from employees where eid = (select max(eid) from
employees where eid in (select top 5 * from employees))
 
Is This Answer Correct ?    2 Yes 1 No
Nataraj M
 
  Re: how do we find every fifth record in a table
Answer
# 9
select id ,partcode from prt where id in
(

select  case when row_number() over (order by partcode ) % 
5 = 0
			 then row_number() over (order by 
partcode)
			else 0 end
from prt
)
 
Is This Answer Correct ?    0 Yes 0 No
Saurabh Tyagi
 
  Re: how do we find every fifth record in a table
Answer
# 10
Select Top 1 * From (Select Top 5 * From customer Order By 
1 Desc) As X
 
Is This Answer Correct ?    1 Yes 0 No
Divya Mahendra Sikarwar
 
  Re: how do we find every fifth record in a table
Answer
# 11
If we consider employee2 table having 16 records like

Name              Salary
Ajith              10000
Arithas            2000
Balaji             20000 
Gamesh             20000
Jith               23000
keerthy            14000
boopathy           21000        
moorthy            12000
Muthu Krishnan     30000
Muthu Kumar        80000 
naveen             10200
neerthy            40000
Raja               12000 
Ramesh             12000
sangeeth           1100
Vairam             23000

 
With Temp as
(
	select row_number() over(order by [name]) as 'rno', 
[name] from employee2 
)
select [name],salary from Temp 
where rno%5 = 0


The result..

Name            Salary
Jith	        40000
Muthu Kumar	15000
sangeeth	50000
 
Is This Answer Correct ?    0 Yes 0 No
Saravanan P
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
WHAT IS UNIQUE IDENTIFIER DATA TYPE? Sparsh2
What are the type of Indexes? which one is best, why?  5
How to create logins using windows Authentication mode?  2
what is the main difference between after trigger and instead trigger.  1
I have a website that allows customers to browse and place orders for certain products. I have 2 tables; Customers and Orders. The Customers table holds the customer records and the Orders table holds the orders placed by the customer. Both tables are tied based on the field Cust_ID. Example of the data is shown below: Cust_ID Cust_Name Cust_ID Product Amount Order_Date 1001 John Tan 1001 P-5211 $120.00 2/13/2006 1002 Michael Wong 1001 K-1428 $88.90 1/11/2006 1003 Mary Cheong 1003 C-0923 $82.50 1/27/2006 1004 Ahmad Suffian 1003 K-1428 $88.90 2/2/2006 Write a single SQL statement that extracts all purchase records with the following criteria: 1. Customer names starting with “M” only. 2. Orders placed within the current month only. 3. Amount does not exceed $100.00 The list must be sorted by order date with the latest order showing on top. Techno-Solutions3
How to work on DTS?what is the main requirement? ivan1
Can you give an example of Stored Procedure?  2
How do you simulate a deadlock for testing purposes  1
What is the difference between Drop and Truncate  10
i have a table #temp1(id, Name groupname ) and record like this 1 R1 S 2 R3 S 3 R2 S 4 R4 D 5 R5 D 6 R6 K 7 R7 K 8 R8 L 9 R9 L 10 R10 L 11 R11 K and i want to display record based on user defind sorting order e.g. 1 R4 D 2 R5 D 3 R6 K 4 R7 K 5 R11 K 6 R1 S 7 R3 S 8 R2 S 9 R8 L 10 R9 L 11 R10 L  4
What is a view?  4
PC(code, model, speed, ram, hd, cd, price) Find the hard drive sizes that are equal among two or more PCs. APX2
how to know Who Is Blocking Your SQL Server?  3
what is the cursor life span? Evalueserve5
What are the steps you will take, if you are tasked with securing an SQL Server? HCL1
Can we create clustered index on non primary key column CTS14
how we can count records as a group of days like sum of records for(four mondays),(four tuesday)........ in a month. group the column for weekdays.  1
what is Archive old data?  1
Can we create a clustered index on composite primary key.  2
can foreign key take role of primary key? TCS4
 
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