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

What is the difference between syntax error and runtime error?

1183


What is trigger in sql and its types?

1113


What operating systems are supported by oracle sql developer?

1015


What is output spooling in sql*plus?

1092


Who is the owner of mysql database?

1107


How to rename a column in the output of sql query?

1125


When are we going to use truncate and delete?

1022


Is like operator in sql case sensitive?

1077


Why do we need databases?

1089


What is indexes?

1115


How do you write a complex sql query?

1142


What is the difference between microsoft access and sql server?

1106


What are the types of join in sql?

1149


Is sqlite good enough for production?

1046


What is a function in oracle pl sql?

1098