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 the types of resultset?
What is the use of toad or sqldbx.?
What are the differences between triggers and stored procedures?
How to make conditional sum in ssrs?
How to insert multiple rows with one insert statement in ms sql server?
What are drilldown reports?
Explain some stored procedure creating best practices or guidelines?
What is the difference between the 2 operating modes of database mirroring?
Write a program to fetch first 10 records from a file?
What are the different types of sub-queries?
What is sql server programming?
Is sql server implemented as a service or an application? : Sql server database administration
Explain identity in sql server?
What is executereader?
Explain what is sql server english query?