0
如何使用标准和投影来实现下面的代码在休眠:从休眠集团获得最大计数通过
select CUSTOMER_NO,count(*) as max_count
from table
group by CUSTOMER_NO
having count(*) in
(
select
max(count)
from
(
select count(*) as count,CUSTOMER_NO
from table
group by CUSTOMER_NO
) t1
)
假设有两个客户相同的计数这是不行的... – Thomas
criteria.setProjection(Projections.projectionList()。添加(Projections.property( “CUSTOMER_NO”))。添加( Projects.sqlGroupProjection(“CUSTOMER_NO”,“CUSTOMER_NO having count(*)=(select max(tbl.c)as count from(select count(*)as c from temp.t group by CUSTOMER_NO)as tbl)“,new String [] {},new Type [] {}))); –
select count(*)as count,CUSTOMER_NO from temp.t group by CUSTOMER_NO have count(*)=(select max(tbl.c)as count from(从temp.t group by CUSTOMER_NO选择count(*)as c)作为tbl); –