表id  fenshu
1     90
2     95
3     85
4     70
5      95
id为自动编号

解决方案 »

  1.   

    declare @t table(id  int,fenshu int)
    insert into @t select 1,90
    union all select 2,95
    union all select 3,85
    union all select 4,70
    union all select 5,95select id,
           case when id%2=0 then fenshu+10 else fenshu-10 end as fenshu
    from @t --这样?
      

  2.   


    create table tb1(id int identity(1,1),fenshu int)
    insert into tb1 (fenshu)
    select 90 union all
    select 95 union all
    select 85 union all
    select 70 union all
    select 95goupdate tb1
    set fenshu= (case when id %2=0 then fenshu+10 else fenshu-10 end )
    select * from tb1godrop table tb1
      

  3.   

    DECLARE @DATA TABLE(ID INT IDENTITY(1, 1), FENSHU INT)
    INSERT INTO @DATA
    SELECT 90
    UNION
    SELECT 95
    UNION
    SELECT 85
    UNION
    SELECT 70
    UNION
    SELECT 95SELECT
    ID,
    CASE WHEN ID % 2 = 0 THEN FENSHU + 10 ESLE FENSHU - 10 END AS FENSHU
    FROM @DATA
      

  4.   

    我好像也出来了update table set fenshu=fenshu+10 where id%2=0
    update table set fenshu=fenshu-10 where id%2=1
    对吗,      我明天早上结,谢谢大家
      

  5.   

    update的话,用太多借口的就可以了。case when