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 the encryption mechanisms in sql server?

579


What is bookmark link in ssrs?

108


How can I check if a view exists in a sql server database?

567


Is t sql the same as sql server?

522


Can primary key be a foreign key?

566






Explain query editor regions

619


What is the use of for clause?

585


What is trace flag in sql server?

532


what is database replicaion? What are the different types of replication you can set up in sql server? : Sql server database administration

534


What do you understand by intent locks?

577


What is the difference between char and varchar2 datatype in sql?

549


What is a constant or literal in ms sql server?

603


What is the difference between truncate and delete commands?

571


What is temporal data type?

526


How can we determine what objects a user-defined function depends upon?

524