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


Please Help Members By Posting Answers For Below Questions

Explain select statements in sql?

756


Can we insert data into view?

678


what is index? : Sql dba

746


What is error ora-01000: maximum open cursors exceeded

783


What are the three pl sql block types?

715






What's the difference between inner join and left join?

722


What is meant by user defined function?

761


Is a table valued function object?

757


Define commit?

741


what are null values? : Sql dba

705


i have a column which may contain this kind of value: 123*67_80,12*8889_5,34*8_874 ,12*7_7 (can contain space before a comma, and this string length can be anything) now i want to split this value into two column like: column1: 123*67,12*8889,34*8,12*7 column2: 80,5,874,7 use function for this

1277


What are the usages of sql?

750


Explain what is a view?

793


How to add, remove, modify users using sql?

741


What is record variable?

705