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
how to show all tables with 'mysql'? : Sql dba
How long it takes to learn pl sql?
What is pl sql script?
Will truncate release space?
What port does sql server use?
How can we solve sql error: ora-00904: invalid identifier?
what is bdb (berkeleydb)? : Sql dba
What is left join in sql?
Is sqlite free?
Are stored procedures faster than queries?
What is a natural join?
What are triggers and its uses?
What is Histogram?
Can primary key be changed?
Are left and right joins the same?