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 are the security recommendations while using mysql? : Sql dba

1049


What information is needed to connect sql*plus an oracle server?

978


What are analytical functions in sql?

969


Why indexing is needed?

939


Is join same as left join?

978


Which is faster truncate or drop?

981


what is cross join? : Sql dba

938


What is the purpose of design view?

950


i have a column which may contain this kind of value: 123*67_80,12*8889_5,34*8_874 ,12*7_7 (can contain space before a comma, and this string length can be anything) now i want to split this value into two column like: column1: 123*67,12*8889,34*8,12*7 column2: 80,5,874,7 use function for this

1537


What are the limitations of sql express?

985


How many subqueries can be nested in a statement?

933


Can 2 queries be executed simultaneously in a distributed database system?

1082


What is a database event trigger?

1081


What is sql query limit?

911


what are local and global variables and their differences? : Sql dba

1009