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 do I view a table in sql?
Can you inner join the same table?
What is the use of triggers?
What is informix sql?
What is native sql query?
what is the difference between char_length and length? : Sql dba
How to Declare Fixed Length String Value In PL SQL
What is the size of partition table?
Is sql a backend language?
Is primary key a clustered index?
how to return query output in html format? : Sql dba
How does join work in sql?
Can we rollback delete command?
What are sql injection vulnerabilities?
what does it mean to have quoted_identifier on? What are the implications of having it off? : Sql dba