select f1,sum(f2) from table group F1

解决方案 »

  1.   

    select f1,sum(f2) from table group  by F1
      

  2.   

    TRY:
    select sum (f2) from (select f1,mix(f2) f2 from table group  by F1)
      

  3.   

    select DISTINCT f1,sum(f2) from table group  by F1
    采用DINSTINCT函数去除重复的记录
      

  4.   

    select sum(f2) from (select f1,max(f2) f2 from table group  by F1)aa
      

  5.   

    select sum (f2) from (select f1,mix(f2) f2 from table group  by F1) aaorselect sum (f2) from (select distinct f1,f2 from table) aa
      

  6.   

    楼上的可以啦。
    不知道这样可不可以, 你试试吧。。
    select sum(f2) from table where f1 in (select distinct(f1) from table)
      

  7.   

    楼上的,不行,table 里有很多重复的 f1,select sum(f2) from (select distinct(f1), f2 from table) A
      

  8.   

    select sum(f2)
    from
    (select distinct f1,f2 from tablename)
      

  9.   

    select sum (f2) from (select distinct f1,f2 from table)aa 可以了,谢谢大力兄。
    不过还有个条件: t1表的f1内联到t2表的f1怎么把这两部分组和在一起呢?我试了一下
    select sum (f2) from t1 inner join t2 on t1.f1=t2.f1 and t1.f1 like 'dddd%',(select distinct f1,f2 from table)aa 长时间不返回
      

  10.   

    TRY:
    select sum (f2) from (select t1.f1,max(t2.f2) f2 from t1 inner join t2 on t1.f1=t2.f1 and t1.f1 like 'dddd%')aa
      

  11.   

    select a.f1,sum(a.f2) as f2 
    from (select distinct t2.f1,t2.f2 from t1 inner join t2 on t1.f1=t2.f1 and t1.f1 like 'dddd%') a
    group by a.f1
    按照这个思路就可以了
      

  12.   

    select f1,F2=sum(IsNull(F2,0)) from table group by F1
      

  13.   

    ibanez550运行不了,返回错误信息
    "the column prefix "t1" does not match with a table name or alias name used in the query."
      

  14.   

    select a.f1,sum(a.f2) as f2 
    from (select distinct t1.f1(这儿,条件的),t2.f2 from t1 inner join t2 on t1.f1=t2.f1 and t1.f1 like 'dddd%') a
    group by a.f1
    你可以这样试试