0

I need to fetch output from given below table in 0 1 0 1 sequence .All other data at the end of table.

create table #Temp
(
    EventID INT IDENTITY(1, 1) primary key ,
    Value bit
)
INSERT  INTO  #Temp(Value) Values
(0),(1)
,(0),(0)
,(0),(0)
,(0),(0)
,(1),(1)
,(1),(1)
,(1),(0)
,(0),(0)
,(1),(1)
,(0),(1)
Marco Bong
  • 690
  • 4
  • 13
Gaurav
  • 5
  • 4

1 Answers1

1

This is probably what you want:

select *
from #Temp
order by row_number() over (partition by Value order by EventID), Value
dnoeth
  • 59,503
  • 4
  • 39
  • 56