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

What is the cause of mutating table error and how can we solve it?

1066


What do you mean by stored procedures? How do we use it?

1005


Why do we use set serveroutput on?

981


Explain autonomous transaction.

1168


How can use stored procedures in sql?

1149


How you improve the performance of sql*loader? : aql loader

1021


How many types of cursors are available in pl/sql?

1120


What does count (*) mean in sql?

1598


Is mariadb nosql?

1049


Can variables be used in sql statements?

1045


what is data manipulation language? : Sql dba

1027


What is meant by user defined function?

1059


How do I order by ascending in sql?

1034


Does truncate table reset auto increment?

1003


What is normalization in a database?

1169