Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 the difference between cursor declared in procedures and cursors declared in the package specification?

1131


What is clause?

1137


Explain clause in sql?

1018


What is field delimiter?

1040


what is bdb (berkeleydb)? : Sql dba

1022


Explain the difference between 'between' & 'and' operators in sql

991


What is execute immediate?

1074


What is difference between primary and secondary key?

1018


What are sql injection vulnerabilities?

976


where are cookies actually stored on the hard disk? : Sql dba

1020


Mention what does plv msg allows you to do?

1107


what is oracle database ? : Sql dba

1014


Why do we use triggers?

963


Give the order of sql select?

1129


How do you determine the current isolation level? : Transact sql

1146