hql 分组 排序
"select basic.emploree,avg(basic.mark) from Basic basic group by basic.emploree order by avg(basic.mark) desc";
emploree是实体类
emploree和basic是一对多
执行后报emploree.id不在group by子句
------解决方案--------------------join fetch连接查询,这样会查出所有属性,而且只会发一条sql语句。
select basic.emploree,avg(basic.mark) from Basic basic join fetch basic.emploree group by basic.emploree.id order by avg(basic.mark) desc;