码迷,mamicode.com
首页 > 其他好文 > 详细

hql中不能写count(1)可以写count(a.id)

时间:2014-06-10 14:54:59      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:style   code   ext   color   com   string   

hql中不能写count(1)可以写count(a.id)里面写具体的属性

 

String hql="select new com.haiyisoft.vo.entity.cc.repo.BusinessStat(  r.paramName ,t.paramName , "
         +" (select nvl(count(1),0) "
         +" from com.haiyisoft.entity.cc.busi.Business b,com.haiyisoft.entity.cc.busi.Application a,com.haiyisoft.entity.cc.busi.Channel c "
         +" where b.applicationId=a.id and a.appChannel=c.id "
         +" and b.servTime>=to_date(‘" + bgTime + "‘,‘yyyy-mm-dd HH24:mi:ss‘)"
         +" and b.servTime<=to_date(‘" + edTime + "‘,‘yyyy-mm-dd HH24:mi:ss‘)"
         +" and c.channelCode=r.paramCode and substr(b.busiType,0,2)=t.paramCode) as businum)"
         +" from "
         +" ExtendParamValue r,"
         +" ExtendParamValue t"
         +" where "
         +" r.dimension=‘CC_CHANNEL_CODE‘"
         +" and t.dimension=‘CC_BUSI_TYPE‘ "
         +" and length(t.paramCode)=2"
         +" order by r.paramCode,t.paramCode";
  

一开始写成count(1) 一直出不认识1,一直没在意,整了半天以为别的地方写错了,最后把count(1)变成count(a.id)可以了

hql中不能写count(1)可以写count(a.id),布布扣,bubuko.com

hql中不能写count(1)可以写count(a.id)

标签:style   code   ext   color   com   string   

原文地址:http://blog.csdn.net/myfmyfmyfmyf/article/details/29552445

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!