我想求一列数字的和,然后把它输出在另一列上,请问该怎么做?
比如 a   b
     4     
     8
     6
     9
我想让它显示成
    a   b
    4   27  
    8   27
    6   27
    9   27
谢谢高手了!!

解决方案 »

  1.   

    select a,(select sum(a) from 表) b
    from 表
      

  2.   

    update 表 set b=(select sum(a) from 表)
      

  3.   

    select *, b=(select sum(a) from a ) from a   ??
      

  4.   

    create table tb(a int,b int)
    insert into tb(a)
    select  4      
    union select     8
    union select     6
    union select     9select * from tbselect a.a,b=sum(b.a) from tb a,tb b group by a.a
    drop table tb
      

  5.   

    B字段如果是Int类型
    update 表 set b=(select sum(Cast(a as int)) from 表)
      

  6.   

    select a,(select sum(Cast(a as int)) from 表) b
    from 表
      

  7.   

    select *, b=(select sum(cast(a as int)) from a ) from a