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 do you mean by recursive stored procedure?
Why do we use sql limitations? Which constraints can we use while making a database in sql?
You schedule a job to run every minute what will happen if the first job runs more than 1 min? Will the second instance of the job start?
What is full outer join in sql server joins?
How to access the deleted record of an event?
Do you know the cursor types?
How to drop an existing schema in ms sql server?
How to declare a cursor with "declare ... Cursor" in ms sql server?
What is the purpose of self join?
What is difference between delete and truncate commands?
What are the different types of collation sensitivity?
What it means to be triggered?
Differentiate between a primary key and a unique key.
What causes index fragmentation?
Explain different types of index?