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 |
What is SQL Profiler what is the use of it?
2 Answers 247Customer, Steria,
1.what is the diff between nolock optimizer and read uncommitted isolation? 2.what is the diff between revoke and deny? 3.what is percieved down time? 4.whether password protection are required for backups?if yes why?if no why? 5.what is fill factor? 6.what is cost analysis? 7.what is mean by piece meal restore? 8.what is 'rowguidcol'? 9.impersonate permission? 10.what is selectivity?
What are the magic tables in SQL Server 2000?
7 Answers Infogain, Merrill Lynch,
How is foreign key related to primary key?
How to delete duplicate rows?
What is the osql utility?
How to retrieve error messages using odbc_errormsg()?
What is unpivot?
What is isolation levels?
How can we get count of the number of records in a table?
Rate yourself in .NET and SQL ?
1 Answers Cognizant, HCL, SunGard,
What is the use of attributehierarchyvisible ? : sql server analysis services, ssas
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)