alter table tb add I_O varchar(1)
update tb set I_O='I' where cast(id as numeric(12,2)/2<>id/2
update tb set I_O='O' where cast(id as numeric(12,2)/2=id/2
update tb set I_O='I' where cast(id as numeric(12,2)/2<>id/2
update tb set I_O='O' where cast(id as numeric(12,2)/2=id/2
,(case when t.id=(select min(id) from 表 where [date]=t.[date])
then 'I'
else 'O'
end
) as 'I_O'
from 表 t
select *
,(case when (select count(1) from 表 where id<=t.id)%2=1)
then 'I'
else 'O'
end
) as 'I_O'
from 表 t