I have two joined tables, one to many. The problem I'm having, is the field that they are joined on, is the one I'm trying to count. So access is counting them in the wrong table, basically.
Here is the SQL:
SELECT DISTINCTROW Contracts.ProductID, Count(Contracts.[Contract No]) AS [CountOfContract No], Min(ItemsOrdered.[Line Start Date]) AS [MinOfLine Start Date]
FROM Contracts INNER JOIN ItemsOrdered ON Contracts.[Contract No] = ItemsOrdered.[Contract No]
WHERE (((Contracts.[Date Activated in OKS]) Is Null))
GROUP BY Contracts.ProductID;
Somehow, that returns the count (I checked by hand) from the ItemsOrdered table. I've tried deleting the join of the tables, but that definitely didn't work. I've tried adding the Contract No field from ItemsOrdered and setting it to Group By....nope.
Not sure what else to try here. Do I need to remove the Items Ordered table from the query? And if I do that how do I get the field that I need from it?
I have searched and found references fro sub-queries, and adding Distinct to the count. But none of the examples I've found seem to work for this one.
Any ideas would be much appreciated, Thanks!!
Here is the SQL:
SELECT DISTINCTROW Contracts.ProductID, Count(Contracts.[Contract No]) AS [CountOfContract No], Min(ItemsOrdered.[Line Start Date]) AS [MinOfLine Start Date]
FROM Contracts INNER JOIN ItemsOrdered ON Contracts.[Contract No] = ItemsOrdered.[Contract No]
WHERE (((Contracts.[Date Activated in OKS]) Is Null))
GROUP BY Contracts.ProductID;
Somehow, that returns the count (I checked by hand) from the ItemsOrdered table. I've tried deleting the join of the tables, but that definitely didn't work. I've tried adding the Contract No field from ItemsOrdered and setting it to Group By....nope.
Not sure what else to try here. Do I need to remove the Items Ordered table from the query? And if I do that how do I get the field that I need from it?
I have searched and found references fro sub-queries, and adding Distinct to the count. But none of the examples I've found seem to work for this one.
Any ideas would be much appreciated, Thanks!!