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

Which table is left in join?

958


What is use of trigger?

909


how can we know the number of days between two given dates using mysql? : Sql dba

1028


What does closing a cursor do?

1303


What is difference between nchar and nvarchar?

1008


How does cross join work in sql?

1002


explain primary keys and auto increment fields in mysql : sql dba

950


How long does it take to learn pl sql?

1045


How do you rename a table in sql?

1085


What does trigger mean in slang?

1034


explain the difference between bool, tinyint and bit. : Sql dba

977


what is a primary key? : Sql dba

1026


Is natural join and inner join same?

902


What is sql trigger example?

1033


How do you update sql?

955