문제

Here is what I'm trying to do. get a sum of the count of values from a table based on specific criteria and have this return as a column of the parent select, but I'm having trouble getting my head around the best (i.e. a workable) method for doing this. I've tried

SELECT
sum(count(distinct(frsrvdate)))
FROM webusers.tblQAuditClaims qac inner join webusers.tblQAuditDetails qad using (claimId)
where qac.auditdate between '2012-01-01' and '2012-03-31'
and IsResubmitted = 0
and qad.errorflag = 0
and qac.errorflag = 0
which throws an invalid group function.   

Starting to think I'm going down the wrong rabbit hole with my approach to this. Any suggestions on what I'm missing?

I've pared it down to the subselect piece but still running in to problems on how to get a sum of the count.

도움이 되었습니까?

해결책

In the first query you have an extra ).

Corrected one -

sum(SELECT count(distinct(FrSrvDate))
     FROM webusers.tblQAuditClaims qac Left Join webusers.tblQAuditDetails qad using     (claimId)
     where qac.auditdate between '2012-01-01' and '2012-03-31'
     and IsResubmitted = 0
     and qad.errorflag = 0
     group by tracenumber)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top