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

解决方案 »

  1.   

    select * 
           ,(case when t.id=(select min(id) from 表 where [date]=t.[date])
                  then 'I'
                  else 'O'
             end
            ) as 'I_O'
    from 表 t
      

  2.   

    看错了:
    select * 
           ,(case when (select count(1) from 表 where id<=t.id)%2=1)
                  then 'I'
                  else 'O'
             end
            ) as 'I_O'
    from 表 t
      

  3.   

    select * ,(case when cast(id as int)%2=1 then 'I' else 'O'  end ) as 'I_O' from 表 t
      

  4.   

    alter table tb add I_O varchar(10)