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 the difference between syntax error and runtime error?
What is trigger in sql and its types?
What operating systems are supported by oracle sql developer?
What is output spooling in sql*plus?
Who is the owner of mysql database?
How to rename a column in the output of sql query?
When are we going to use truncate and delete?
Is like operator in sql case sensitive?
Why do we need databases?
What is indexes?
How do you write a complex sql query?
What is the difference between microsoft access and sql server?
What are the types of join in sql?
Is sqlite good enough for production?
What is a function in oracle pl sql?