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 are commonly used odbc functions in php?
How to drop an existing table with "drop table" statements in ms sql server?
What do you understand by a view? What does the with check option clause for a view do?
What is the difference between the export /import functions in sql studio and standalone sql manager? : sql server management studio
Explain temporary table vs table variable by using cursor alternative?
what's the maximum size of a row? : Sql server database administration
Explain nested trigger in sql?
How to create a view with data from multiple tables?
Can I work with several databases simultaneously? : sql server management studio
What are database states in ms sql server?
What is auditing in sql server?
Can you explain what is sql server english query?
Tell me what do you mean by an execution plan? Why is it used? How would you view it?
How to divide query output into multiple groups with the group by clause in ms sql server?
Mention the differences between substr and charindex in sql server.