I have a rather complex query that is grouping counts. There is one specific field where I need to count distinct values only (but for specific criteria). I am using VFP 9 Beta and trying to use a sub-query in the field list like this (there are a lot more SUM's but I removed them for clarification):
But I get the error: Subquery returned more than one record (Error 1860). I'm probably not using the right syntax. Has anyone done this before? Or if anybody has any ideas about how to do this in VFP 6 that would be great too!
Sebastian
Code:
SELECT County, State, SUM(IIF(LEN(ALLTRIM(fax)) = 10 AND ;
ISDIGIT(fax) AND RSPFlag AND DNC = 0,1,0)) as FaxResp, ;
[B]
(SELECT COUNT(distinct email) FROM csrProspects ;
WHERE '@' $ email AND !RSPFlag AND DNE = 0 ;
GROUP BY County, State) as EmailCount, ;
(SELECT COUNT(distinct email) FROM csrProspects ;
WHERE '@' $ email AND RSPFlag AND DNE = 0 ;
GROUP BY County, State) as EmailResp, ;
[/B]
FROM csrProspects GROUP BY County, State ;
ORDER BY State, County INTO CURSOR csrCounts
Sebastian