Select cl1,sum(cl2) as cl2,sum(cl3) as cl3 
from tb
group by cl1

解决方案 »

  1.   

    Select   cl1,sum(cl2)   as   cl2,sum(cl3)   as   cl3   
    from   tb 
    group   by   cl1
    order by cl1
      

  2.   


    Select   cl1,sum(cl2)   as   cl2,sum(cl3)   as   cl3  
    from   tb
    group   by   cl1
      

  3.   

    select cl1 , cl2 = sum(cl2) , cl3 = sum(cl3) from tb group by cl1
      

  4.   

    --updateupdate tb
    set cl2 = t.cl2,
        cl3 = t.cl3
    from tb,(select cl1 , cl2 = sum(cl2) , cl3 = sum(cl3) from tb group by cl1) t
    where tb.cl1 = t.cl1