亲爱的朋友们,我需要从一张具有不同标准的表中获取计数(*)。我正在使用带有spring的hibernate。我正在使用下面的查询。
"select " +
"(select count(*) from enquiry where business_id="+busid+") AS allEnqCount,"+
"(select count(*) from enquiry where status='"+Constants.ENQ_FALLOWUP+"' and us.business_id="+busid+") AS followupCount," +
"(select count(*) from enquiry where status='"+Constants.ENQ_SITE_VISIT+"'and us.business_id="+busid+") AS siteVisitCount ," +
"(select count(*) from enquiry where status='"+Constants.ENQ_CUST_VISIT+"'and us.business_id="+busid+") AS customerVisitCount," +
"(select count(*) from enquiry where status='"+Constants.ENQ_OFFICE_VISIT+"'and us.business_id="+busid+") AS officevisitCount,"+
"(select count(*) from enquiry where status='"+Constants.ENQ_PENDING+"'and us.business_id="+busid+") AS pending";
但它需要相当多的时间。你能告诉我有没有什么方法可以用最少的时间和一个单一的选择子句来做到这一点。
提前致谢。