DCount or DISTINCT in Crosstab query

kvar

Registered User.
Local time
Today, 09:04
Joined
Nov 2, 2009
Messages
77
I have a crosstab query, among other things, it counts the field Policy Number to tell me how many policies were sold. Those are a unique value anyway so that count is accurate. I'm also trying to get it to tell me the number of agents that sold those policies. I need it to count the Agent # but only to count unique values. Obviously 1 agent could have sold many more than one policy.
Here is what I have so far, all of my attempts to add a DCount or DISTINCT have just resulted in errors so any help or direction is much appreciated!!

TRANSFORM Sum([__Face Amount]/[SumOf__Face Amount]) AS PercentOfSales
SELECT EA_PrimaryAgent_tbl.[DISTRICT #], Count(EA_ActiveLife_West.[__Policy Nbr]) AS [CountOf__Policy Nbr], Count(EA_ActiveLife_West.[AGENT #]) AS [Agents Selling]
FROM EA_ActiveLife_WEST_TotalYTDSales_qry RIGHT JOIN ((EA_ActiveLife_West LEFT JOIN LifeProductList_tbl ON EA_ActiveLife_West.[__Product Long Name] = LifeProductList_tbl.[Product Long Name]) LEFT JOIN EA_PrimaryAgent_tbl ON EA_ActiveLife_West.PrimaryAgentNumber = EA_PrimaryAgent_tbl.[AGENT #]) ON EA_ActiveLife_WEST_TotalYTDSales_qry.[DISTRICT #] = EA_PrimaryAgent_tbl.[DISTRICT #]
WHERE (((Year([__Issue Date]))=Year(Date())))
GROUP BY EA_PrimaryAgent_tbl.[DISTRICT #]
PIVOT LifeProductList_tbl.[Term/Perm];
 
Oh if I only I could name the fields. Lol. Would save me a lot of headaches.
I was afraid that was going to be the answer, was really hoping I was wrong. Oh well, worth a shot. Thank you!
 

Users who are viewing this thread

Back
Top Bottom