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
Explain select statements in sql?
Can we insert data into view?
what is index? : Sql dba
What is error ora-01000: maximum open cursors exceeded
What are the three pl sql block types?
What's the difference between inner join and left join?
What is meant by user defined function?
Is a table valued function object?
Define commit?
what are null values? : Sql dba
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
What are the usages of sql?
Explain what is a view?
How to add, remove, modify users using sql?
What is record variable?