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
What is pivot in sql?
What is the starting oracle error number?
What is primary key and foreign key?
What are the 3 modes of parameter?
What will you get by the cursor attribute sql%found?
Can we use commit inside a trigger?
What is the difference between a primary key and a unique key?
explain mysql aggregate functions. : Sql dba
What are hotfixes and patches?
What is normalization sql?
how do you know if your mysql server is alive? : Sql dba
Write a unique difference between a function and a stored procedure.
How do I audit the sql sent to the server?
What is a memo field?
How do you bind variables in pl sql?