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 use 'mysql' to run sql statements? : Sql dba
What are its different types of dbms?
What is sql exception?
What can sql server reporting services do?
Can I join the same table twice?
Is sql difficult?
Do triggers have restrictions on the usage of large datatypes, such as long and long raw?
How many subqueries can be nested in a statement?
What are different sql data types?
what is a view? : Sql dba
What happens when a trigger is associated to a view?
What is a pl/sql block?
What is data abstraction in sql?
When sql appeared?
When to use inner join and left join?