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 to write the query to select the rows are in the order
of either 1,3,5,7... or 2,4,6,8,...

Answer Posted / rajesh verma

1> incase of 2,4,6,8,...

select col1,col2 from tab1 where col1 in
(Select case when Row_number() over (order by col1)%2=0
then col1 else 0 end from tab1)

2> in case of 1,3,5,7,....

select col1,col2 from tab1 where col1 in
(Select case when Row_number() over (order by col1)%2=1
then col1 else 0 end from tab1)

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the optimization being performed in oracle and SQL Server?

1099


What extended events?

1063


How to delete duplicate rows from table except one?

1047


What is the difference between executequery () and executeupdate ()?

1114


What is the difference between update lock and exclusive lock?

1028


What are the types of table?

1031


Explain insert into select statement?

1011


How can you ensure that the database and sql server based application perform well?

1126


What is a rownum?

1063


Why would you call update statistics?

1076


What is factless fact table? : sql server analysis services, ssas

1098


How to backup encryption key ?

191


What is difference between clustered index and non clustered index?

1126


What do we need queues in sql service broker?

1124


What is difference between line feed ( ) and carriage return ( )?

951