how to write the query to select the rows are in the order
of either 1,3,5,7... or 2,4,6,8,...
Answers were Sorted based on User's Feedback
Answer / senthil
select * from dbo.outs_OpenItems where OIR_ID % 2=1
Is This Answer Correct ? | 20 Yes | 9 No |
Answer / vijay sultampur
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 ? | 7 Yes | 0 No |
Answer / rajesh verma
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 ? | 6 Yes | 1 No |
Answer / leo
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 ? | 4 Yes | 1 No |
Answer / md. niyaz
For: 2, 4, 6, ......
select * from <Table_Name> where <Column_Name> % 2 = 0
==============Niyaz====================================
For: 1, 3, 5, ......
select * from <Table_Name> where <Column_Name> % 2 = 1
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / vijayplsql@gmail.com
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 |
Answer / tiru
select * from
(select emp.ename, emp.age, (rownum+1) AS XX from employee
emp )
where remainder(XX,2) = 0;
select * from
(select emp.ename, emp.age, (rownum+1) AS XX from employee
emp )
where remainder(XX,2) = 1;
Is This Answer Correct ? | 0 Yes | 0 No |
How to delete an existing row with delete statements in ms sql server?
What is difference between view and materialized view?
If you are given access to a SQL Server, how do you find if the SQL Instance is a named instance or a default instance?
what is statistics
what is unique and xaml nonclustered index
Explain what is public role in sql server?
Explain what are the database objects? : SQL Server Architecture
how to count datewise data in sqlserver
4 Answers CarrizalSoft Technologies, IndusInd Bank,
Name 3 of the features that the sql server built-in function loginproperty performs on standard logins? : sql server security
What is an execution plan? When would you use it? How would you view the execution plan?
How does using a separate hard drive for several database objects improves performance right away?
What is Pointer ?
3 Answers Cap Gemini, CarrizalSoft Technologies,