Link to home
Start Free TrialLog in
Avatar of rustyroo
rustyrooFlag for Australia

asked on

Distinct Count in Access 2007

Hey guys,

Need to count distinct invoice numbers in the below query.  Have tried lots of ways to no effect... can someone please assist.

thanks

Rusty


SELECT [Working-rep+acc].[Sales Rep], Count ([Working-rep+acc].[Invoice Number]) AS  [CountOfInvoice Number]
FROM [Working-rep+acc]
GROUP BY [Working-rep+acc].[Sales Rep];
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

You just need to group by the Invoice Number as well.

SELECT [Working-rep+acc].[Sales Rep], [Working-rep+acc].[Invoice Number], Count ([Working-rep+acc].[Invoice Number]) AS  [CountOfInvoice Number]
FROM [Working-rep+acc]
GROUP BY [Working-rep+acc].[Sales Rep], [Working-rep+acc].[Invoice Number];
Avatar of FarWest
FarWest

in access you should use sub-query for your select that contains the distinct select
something like

SELECT t.[Sales Rep], Count (t.[Invoice Number]) AS  [CountOfInvoice Number]
FROM (
SELECT distinct [Working-rep+acc].[Sales Rep], [Working-rep+acc].[Invoice Number]) AS t
GROUP BY [Working-rep+acc].[Sales Rep];
ASKER CERTIFIED SOLUTION
Avatar of als315
als315
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rustyroo

ASKER

worked great thanks