这个在数据库里面建不成表啊。如果要建立表的话,先要把你的表结构重新设计一下

解决方案 »

  1.   

    按照这种格式不能够查询出来吗,或者是用其它的方法解决这个问题
      

  2.   


    --> --> (让你望见影子的墙)生成測試數據
     
    if not object_id('tb') is null
    drop table tb
    Go
    Create table tb([序号] int,[学号] int,[基础分1] int,[奖励分1] int,[惩罚分1] int,[基础分2] int,[奖励分2] int,[惩罚分2] int,[基础分3] int,[奖励分3] int,[惩罚分3] int,[基础分4] int,[奖励分4] int,[惩罚分4] int)
    Insert tb
    select 1,221,80,2,1,80,2,1,80,2,1,80,2,1 union all
    select 2,222,80,2,1,80,2,1,80,2,1,80,2,1 union all
    select 3,223,80,2,1,80,2,1,80,2,1,80,2,1 union all
    select 4,224,80,2,1,80,2,1,80,2,1,80,2,1 union all
    select 5,225,80,2,1,80,2,1,80,2,1,80,2,1 union all
    select 6,226,80,2,1,80,2,1,80,2,1,80,2,1 union all
    select 7,227,80,2,1,80,2,1,80,2,1,80,2,1 union all
    select 8,228,80,2,1,80,2,1,80,2,1,80,2,1 union all
    select 9,229,80,2,1,80,2,1,80,2,1,80,2,1
    Go
    Select * from tb
    select 学号,基础分1=基础分1+isnull((select 基础分1 from tb where 序号=t.序号+1),0),
        奖励分1=奖励分1+isnull((select 奖励分1 from tb where 序号=t.序号+1),0),
                惩罚分1=惩罚分1+isnull((select 惩罚分1 from tb where 序号=t.序号+1),0),
                基础分2=基础分2+isnull((select 基础分2 from tb where 序号=t.序号+1),0),
                奖励分2=奖励分2+isnull((select 奖励分2 from tb where 序号=t.序号+1),0),
                惩罚分2=惩罚分2+isnull((select 惩罚分2 from tb where 序号=t.序号+1),0),
                基础分3=基础分3+isnull((select 基础分3 from tb where 序号=t.序号+1),0),
                奖励分3=奖励分3+isnull((select 奖励分3 from tb where 序号=t.序号+1),0),
                惩罚分3=惩罚分3+isnull((select 惩罚分3 from tb where 序号=t.序号+1),0),
        基础分4=基础分4+isnull((select 基础分4 from tb where 序号=t.序号+1),0),
                奖励分4=奖励分4+isnull((select 奖励分4 from tb where 序号=t.序号+1),0),
                惩罚分4=惩罚分4+isnull((select 惩罚分4 from tb where 序号=t.序号+1),0)
    from tb t
    where 序号%2<>01 221 80 2 1 80 2 1 80 2 1 80 2 1
    2 222 80 2 1 80 2 1 80 2 1 80 2 1
    3 223 80 2 1 80 2 1 80 2 1 80 2 1
    4 224 80 2 1 80 2 1 80 2 1 80 2 1
    5 225 80 2 1 80 2 1 80 2 1 80 2 1
    6 226 80 2 1 80 2 1 80 2 1 80 2 1
    7 227 80 2 1 80 2 1 80 2 1 80 2 1
    8 228 80 2 1 80 2 1 80 2 1 80 2 1
    9 229 80 2 1 80 2 1 80 2 1 80 2 1
      

  3.   

    你的原来的格式不符合数据库的基本要求,所以只能稍微修改下。
      

  4.   

    不好意思,结果贴错了。221 160 4 2 160 4 2 160 4 2 160 4 2
    223 160 4 2 160 4 2 160 4 2 160 4 2
    225 160 4 2 160 4 2 160 4 2 160 4 2
    227 160 4 2 160 4 2 160 4 2 160 4 2
    229 80 2 1 80 2 1 80 2 1 80 2 1