各位大虾好 
查询一张表里的信息,需要把编码相同的金额累加起来,在返回累加后的信息 怎么写sql语句了

解决方案 »

  1.   

    select 编码 ,sum(金额)as ammount from table  group by 编码 
      

  2.   

    select 编码,sum(金额) from tb group by 编码
      

  3.   

    select 编码,sum(金额) from tb group by 编码
      

  4.   

    select 编码,sum(金额),min(其他数据) from tb group by 编码
      

  5.   


    select 编码,sum(金额),min(其他数据) from tb group by 编码或者select 编码,sum(金额),其他数据 from tb group by 编码,其他数据
      

  6.   

    select 编码,sum(金额),其他数据字段 from tb group by 编码
      

  7.   


    Select t1.编码,t1.名称... ,t2.合计数据 From t1
    Left Join (Select t1.编码,sum(数据) as '合计' From t1) as t2 On(t1.编码 = t2.编码)
    具体代码还得根据实际情况,这样写在字段比较多的时候相对来说思路比较清晰
      

  8.   

    select 编码,sum(金额) from tb group by 编码
      

  9.   

    select 编码 ,sum(金额)as TOTAL from TB group by 编码 ?
      

  10.   

    select a.其他数据, a.编码,b.TOTAL from TB a
    inner join (select 编码 ,sum(金额)as TOTAL from TB group by 编码 
    ) b on a.编码 = b. 编码
      

  11.   

    Select t1.* ,t2.合计 From table  
    Left Join 
    (Select 编码,sum(数据) as '合计' From table  group by 编码 ) as aa
     On table.编码 = aa.编码 
      

  12.   

    GROUP BY   灵活运用
      

  13.   


    直接给数据吧,没数据都不知道你想要什么暂时只能这么写select 编码,sum(金额) from tb group by 编码