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)
This is probably what you want:
select *
from #Temp
order by row_number() over (partition by Value order by EventID), Value