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

how to show all tables with 'mysql'? : Sql dba

1058


How long it takes to learn pl sql?

947


What is pl sql script?

975


Will truncate release space?

883


What port does sql server use?

985


How can we solve sql error: ora-00904: invalid identifier?

1161


what is bdb (berkeleydb)? : Sql dba

968


What is left join in sql?

1003


Is sqlite free?

907


Are stored procedures faster than queries?

895


What is a natural join?

988


What are triggers and its uses?

997


What is Histogram?

1500


Can primary key be changed?

861


Are left and right joins the same?

997