How One can easily select all even, odd, or Nth rows from a
table using SQL queries?
Answer Posted / guru
Please Use Below Query and Kindly post reply feedback
Odd number of records:
select * from emp where (rowid,1) in (select rowid,
mod(rownum,2) from emp);
Output:-
1
3
5
Even number of records:
select * from emp where (rowid,0) in (select rowid,
mod(rownum,2) from emp)
Output:-
2
4
6
For nth number,
Example we r considering number n=10
select * from emp where (rowid,0) in (select rowid,
mod(rownum,10) from emp)
| Is This Answer Correct ? | 18 Yes | 8 No |
Post New Answer View All Answers
Explain the difference between cursor declared in procedures and cursors declared in the package specification?
What is clause?
Explain clause in sql?
What is field delimiter?
what is bdb (berkeleydb)? : Sql dba
Explain the difference between 'between' & 'and' operators in sql
What is execute immediate?
What is difference between primary and secondary key?
What are sql injection vulnerabilities?
where are cookies actually stored on the hard disk? : Sql dba
Mention what does plv msg allows you to do?
what is oracle database ? : Sql dba
Why do we use triggers?
Give the order of sql select?
How do you determine the current isolation level? : Transact sql