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 are commonly used odbc functions in php?

1013


How to drop an existing table with "drop table" statements in ms sql server?

1086


What do you understand by a view? What does the with check option clause for a view do?

998


What is the difference between the export /import functions in sql studio and standalone sql manager? : sql server management studio

1139


Explain temporary table vs table variable by using cursor alternative?

996


what's the maximum size of a row? : Sql server database administration

1081


Explain nested trigger in sql?

1069


How to create a view with data from multiple tables?

1012


Can I work with several databases simultaneously? : sql server management studio

988


What are database states in ms sql server?

1180


What is auditing in sql server?

927


Can you explain what is sql server english query?

994


Tell me what do you mean by an execution plan? Why is it used? How would you view it?

883


How to divide query output into multiple groups with the group by clause in ms sql server?

1033


Mention the differences between substr and charindex in sql server.

1045