mybatis-plus-doc icon indicating copy to clipboard operation
mybatis-plus-doc copied to clipboard

LambdaQueryWrapper 怎么group by 中写select count

Open freshgeek opened this issue 2 years ago • 0 comments

LambdaQueryWrapper 怎么group by 中写select count,


         new LambdaQueryWrapper<SocialRelationCenterTargetDO>()
                        .select(SocialRelationCenterTargetDO::getTargetId,"count(1) as  sum")
                        .in(SocialRelationCenterTargetDO::getTargetId, idSet)
                        .eq(SocialRelationCenterTargetDO::getIdType, idType) 
                .groupBy(SocialRelationCenterTargetDO::getTargetId)

freshgeek avatar Mar 09 '22 05:03 freshgeek

要查groupby后每个targetId的数量吗,我理解LambdaQueryWrapper支持不了,要自己手写原生sql实现了

mabyoung avatar Sep 23 '22 03:09 mabyoung