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 / mritunjay

hi..mr guru all are correct except for the Ntn row
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,1) in (select rowid,
rownum/:N) from emp)

Is This Answer Correct ?    12 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When is the explicit cursor used ?

1023


Why procedure is used in sql?

1030


How to avoid duplicate records in a query?

999


What is cross join sql?

910


Does mysql support pl sql?

1152


I need a function for a train ticket reservation please answer it thanks in advance

1018


How does one use sql*loader to load images, sound clips and documents? : aql loader

1175


What is an intersect?

1096


Why does sql need a server?

1028


Why schema is used in sql?

1040


What is nosql db?

959


Can I copy :old and :new pseudo-records in/to an oracle stored procedure?

1201


What is data profiling in sql?

1064


What are different types of triggers?

1099


What is the difference between sum and count in sql?

981