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
What is the optimization being performed in oracle and SQL Server?
What extended events?
How to delete duplicate rows from table except one?
What is the difference between executequery () and executeupdate ()?
What is the difference between update lock and exclusive lock?
What are the types of table?
Explain insert into select statement?
How can you ensure that the database and sql server based application perform well?
What is a rownum?
Why would you call update statistics?
What is factless fact table? : sql server analysis services, ssas
How to backup encryption key ?
What is difference between clustered index and non clustered index?
What do we need queues in sql service broker?
What is difference between line feed ( ) and carriage return ( )?