In hql, you cannot write count (1) or count (a. id)

Source: Internet
Author: User
In hql, you cannot write count (1) or count (. id. haiyisoft. vo. entity. cc. repo. businessStat (r. paramName, t. paramName, + (selectnvl (count (1), 0) + fromcom. haiyisoft. entity. cc. busi. businessb, com. haiyisoft. enti

In hql, you cannot write count (1) or count (. id) write the specific attribute 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. enti

In hql, you cannot write count (1). You can write specific attributes in 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 ";

At the beginning, I wrote count (1) but never knew 1. I didn't care about it all the time. I thought I was wrong about other places, and finally changed count (1) to count (. id) Yes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.