What could I be doing wrong? I just duplicated what you did and I still
come up with the count multiply itself.
My first Table:
Alarm responses ID Alarm Date
2 1 /31/2005
2 4 /13/2005
2 2 /15/2005
2 6 /12/2005
3 2 /15/2005
3 5 /12/2005
5 6 /1 /2005
15 4 /24/2005
15 6 /18/2005
The second table:
Alarms Initial Renewal Alarm Company Address1 Address2 Exempt Check Type
Paid Permit PermitPrint
No Yes B02 99 Main Street Bldg 99 Main Street
No 1 Fire No 1 No
No Yes B24 A-1 Auto of Somersworth 208 Route 108
No 1 Police Yes 2 No
No Yes 0272 Advance America 110 Tri-City Plaza
No 1 Police Yes 3 No
No Yes 0270 Aikens, Margaret 34 Blackwater Road
Yes 1 Police No 4 No
No Yes 072 18 12 Laurel Lane
No 1 Police No 5 No
No Yes 0256 American Discount Outlets dba Office Price Outlet Store
340 High Street No 1 Police/Fire Yes 6 No
No Yes O0193 Blue Dolphin Screenprint 100 Main Street, 4th Floor
No 1 Police Yes 15 No
I should get a count of 4 for permit #2, acount of 2 for permit#3, 1 for
#5 and 2 for #15. In stead I get 16 for permit #2, 4 for #3, 1 for #5 and
4 for #15.
You said your counts came out correct. Any suggestions?
Thank You,
Loretta
Wayne Morgan said:
I created 2 tables with the names and fields you have listed in your
query. I then put in some dummy companies and dummy response dates. Next,
I copied and pasted your SQL into a query (adjusting for the line wrapping
in the news reader). When I opened the query it showed the number of
responses for each company in the CountOfID field.
--
Wayne Morgan
MS Access MVP
Loretta said:
SELECT DISTINCTROW Count([Alarm responses].ID) AS CountOfID, [Alarm
responses].ID, First(Lookup.Company) AS [First Of Company],
First(Lookup.Address1) AS [First Of Address1], First(Lookup.Address2) AS
[First Of Address2], First([Alarm responses].[Alarm Date]) AS
[FirstOfAlarm Date]
FROM Lookup RIGHT JOIN [Alarm responses] ON Lookup.ID = [Alarm
responses].ID
GROUP BY [Alarm responses].ID;