首页 > 代码库 > 按照group by分组,显示每个人员的分数累计值
按照group by分组,显示每个人员的分数累计值
public List<JfAuction> getListScoreByJfEventId(Integer jfEventId){
List<JfAuction> jfAuctionList=null;
String hql ="select j.id,j.user,j.jfEvent,sum(j.score),j.status,j.createTime from JfAuction j where 1=1 ";
hql+=" and j.jfEvent.id =";
hql+=jfEventId;
hql+=" group by j.user.id";
Query query = jfAuctionDao.getSession().createQuery(hql);
List list=query.list();
if(list!=null && list.size()>0){
jfAuctionList=new ArrayList<JfAuction>();
for(int i=0;i<list.size();i++){
JfAuction jfAuction=new JfAuction();
Object[] obj=(Object[])list.get(i);
System.out.println(obj[0]);
System.out.println(obj[1]);
System.out.println(obj[2]);
System.out.println(obj[3]);
System.out.println(obj[4]);
System.out.println(obj[5]);
jfAuction.setId((Integer)obj[0]);
jfAuction.setUser((User)obj[1]);
jfAuction.setJfEvent((JfEvent)obj[2]);
jfAuction.setScore( Integer.parseInt(obj[3].toString()));
jfAuction.setStatus((Integer)obj[4]);
jfAuction.setCreateTime((Timestamp) obj[5]);
jfAuctionList.add(jfAuction);
}
}
return jfAuctionList;
}
按照group by分组,显示每个人员的分数累计值