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                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
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 to write the query to select the rows are in the order 
of either 1,3,5,7... or 2,4,6,8,...
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: how to write the query to select the rows are in the order of either 1,3,5,7... or 2,4,6,8,...
Answer
# 1
select * from dbo.outs_OpenItems where OIR_ID % 2=1
 
Is This Answer Correct ?    11 Yes 7 No
Senthil
 
  Re: how to write the query to select the rows are in the order of either 1,3,5,7... or 2,4,6,8,...
Answer
# 2
1> incase of 2,4,6,8,...

select col1,col2 from tab1 where col1 in
(Select case when Row_number() over (order by col1)%2=0 
then col1 else 0 end from tab1)

2> in case of 1,3,5,7,....

select col1,col2 from tab1 where col1 in
(Select case when Row_number() over (order by col1)%2=1 
then col1 else 0 end from tab1)
 
Is This Answer Correct ?    4 Yes 0 No
Rajesh Verma
 
 
 
  Re: how to write the query to select the rows are in the order of either 1,3,5,7... or 2,4,6,8,...
Answer
# 3
For 1,3,5,7... 

select * from emp where (rowid,1) in (select rowid,mod
(rownum,2) from emp);

For 2,4,6,8,...

select * from emp where (rowid,0) in (select rowid,mod
(rownum,2) from emp);
 
Is This Answer Correct ?    2 Yes 0 No
Vijay Sultampur
 
  Re: how to write the query to select the rows are in the order of either 1,3,5,7... or 2,4,6,8,...
Answer
# 4
with contactinfo as (
select contactid,firstname,row_number() over (order by 
firstname)as row from person.contact
)
--select * from contactinfo where row % 2 =0
 
Is This Answer Correct ?    2 Yes 0 No
Leo
 
  Re: how to write the query to select the rows are in the order of either 1,3,5,7... or 2,4,6,8,...
Answer
# 5
For 1,3,5,7... 

select * from emp where (rowid,1) in (select rowid,mod
(rownum,2) from emp);

For 2,4,6,8,...

select * from emp where (rowid,0) in (select rowid,mod
(rownum,2) from emp);
 
Is This Answer Correct ?    1 Yes 0 No
Vijayplsql@gmail.com
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
How to find the date and time of last updated table?  3
How can we write or define DDL statements in Sql server and DML statements?  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 is the difference between SSAS 2000 and SSAS 2005? APX1
How will u find the query which is running in some other machine IBM2
What's the difference between a primary key and a unique key?  4
What is the difference between two queries: 1. SELECT * FROM table WHERE 1=1; 2. SELECT * FROM table HP15
1.what is stored procedure?Its significance with example? 2.Explain about index with syntax and example? plz do reply.........  1
Accidentally i deleted my table. How can i get that table?  4
Which command using Query Analyzer will give you the version of SQL server and operating system?  3
What is normalization in Database ?  4
hi, how to match retrieve the unmatched records from 2 tables in which we dont have any primary key. example : table1 has 1,2,3,4,5 and table2 has 1,2,3,4,5,6,7,8,9,10 and i want the numbers from 6 to 10 to be displayed and should not come as null. i need the numbers. please reply as soon as possible.  2
How to Run a Query on a Remote SQL Server?  2
What is data integrity? Explain constraints? Thinksoft1
What are the new features in SQL Server 2005? Emphasis2
Can you have a nested transaction? HCL3
From where can you change the default port?  3
what is Constraint? How many types of constraints in SQL ? NIIT7
What is a view? is View updatable? IBM11
how to find out the repeated value from table using groupby function?  3
 
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