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 sql exception?
What is a heap in sql?
What are the advantages of normalization?
how to drop an existing table in mysql? : Sql dba
How does a self join work?
What schema means?
What is sql in java?
What is rownum?
What are the ddl commands?
Define commit?
Why do we need pl sql?
how to create a new table by selecting rows from another table in mysql? : Sql dba
How much ram can sql express use?
what is a field in a database ? : Sql dba
in oracle 10g sw after compiling procedure how to pass parameter values ,if we (v_empid out number)how to give empid after successful compilation program.This site exact suitable for 10g with respect to question & answer same format , im trying sql browser & sql command prompt using exec procedure name & respective parameters.