本帖最后由 houjialei3 于 2012-02-01 12:41:07 编辑

解决方案 »

  1.   

    你想要的结果里面的1 aaa 25 中, 1本来就没有意义所以只可取部分字段
    select new table(name,sum(count))
    from table  
    group by name
      

  2.   


    谢谢你的回答
    我是这样解决的 
    本来想 直接取出List<实体>集合,带着 sum()函数 不好使select id,name,sum(count)
    from table  
    group by nameList<Object[]> result = query.getResultList();//返回的是Object数组集合
    for(Object obj : result){
      Long id = (Long) obj[0];
      String name = (String) obj[1];
      Long count = (Long) obj[2];
    //然后 new 实体(id,name,count)
    }