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 difference between clustered and non clustered index?
What is intellisense?
What are the instances when triggers are appropriate?
Is ssrs support other database except ms sql server?
What are transactions and its controls?
is there a column to which a default can't be bound? : Sql server database administration
What is the difference between MVC and Teir Architecher? Plz explain with Layyered Programming example...? Thanks
What is a trigger and types of a trigger?
What is mean by candidate key?
What is executereader?
What is the new security features added in sql server 2016? : sql server security
What programming language would you use to create embedded functions in ssrs?
What is the difference between join and inner join?
Can we use where and having clause together?
How can you find out which stored procedures are recompiling?