I have an INSERT
query that is pulling data from two tables and inserting that data into a third table. Everything appears to be working fine except that the COUNT
part of the query isn't returning the results I would expect.
The first set of tables this query runs is MIUsInGrid1000
(number of rows = 1) and Results1000
(number of rows = 24). The number that is returned from the Count
part of the query is 24 instead of being 1 like I would have expected.
The next set of tables is MIUsInGrid1000 (number of rows = 3) and Results1000 (number of rows = 30). The number that is returned from the Count
part of the query is 90 instead of being 3 like I would have expected.
It appears that the product of the two counts is what is being returned to me and I can't figure out why that is. If I take out the references to the Results
tables then the query works the way I would expect. I think that I am misunderstanding how at least some part of this works. Can someone explain why this is not working as I expected it to?
strQuery1 = "Insert Into MIUsInGridAvgs (NumberofMIUs, ProjRSSI, RealRSSI, CenterLat, CenterLong) " & _
"Select Count(MIUsInGrid" & i & ".MIUID), Avg(MIUsInGrid" & i & ".ProjRSSI), Avg(MIUsInGrid" & i & ".RealRSSI), Avg(Results" & i & ".Latitude), Avg(Results" & i & ".Longitude) " & _
"From MIUsInGrid" & i & ", Results" & i & " "