M
MikeB
Hi,
I have three tables (more actually, but only these three are relevant
to this query).
tblLOANS
Key: Text(23)
Status: Text(15)
FK_Group: Text(23)
FK_Member: Text(23)
:
:
tblGROUPS
Key: Text(23)
ShortName: Text(20)
:
:
tblMEMBERS
Key: Text(23)
FK_Group: Text(23)
:
:
Group must have 5 loans AND
Group must have 10 members
I tried the following query, but the count values for both Members and
Loans are equal, not the values in the two tables that I was hoping to
get.
SELECT Group.ShortName, Count(Loan.Key) AS Loans, Count(Member.Key) AS
Members
FROM Member INNER JOIN ([Group] INNER JOIN Loan ON Group.Key =
Loan.GroupKey) ON Member.Key = Group.MemberKey
WHERE (((Loan.Status)="Completed"))
GROUP BY Group.ShortName
HAVING (((Count(Loan.Key))>5) AND ((Count(Member.Key))>10));
I can see that this is wrong, but I just can't figure out how to
construct a correct query.
Thanks
I have three tables (more actually, but only these three are relevant
to this query).
tblLOANS
Key: Text(23)
Status: Text(15)
FK_Group: Text(23)
FK_Member: Text(23)
:
:
tblGROUPS
Key: Text(23)
ShortName: Text(20)
:
:
tblMEMBERS
Key: Text(23)
FK_Group: Text(23)
:
:
groups meeting the following criteria:From these three tables I want to construct a query that will list all
Group must have 5 loans AND
Group must have 10 members
I tried the following query, but the count values for both Members and
Loans are equal, not the values in the two tables that I was hoping to
get.
SELECT Group.ShortName, Count(Loan.Key) AS Loans, Count(Member.Key) AS
Members
FROM Member INNER JOIN ([Group] INNER JOIN Loan ON Group.Key =
Loan.GroupKey) ON Member.Key = Group.MemberKey
WHERE (((Loan.Status)="Completed"))
GROUP BY Group.ShortName
HAVING (((Count(Loan.Key))>5) AND ((Count(Member.Key))>10));
I can see that this is wrong, but I just can't figure out how to
construct a correct query.
Thanks