J
Jack
I have three tables:
Teams(TID,...)
Players(TID<PID<....)(1:M on teams)
Games(TID<GID<....)(1:M onteams)
I want to write a query that gives me the number of players and number of
games for each team
If I use the group by clause on TID and the count on just one of the tables
, I get the correct counts Players(4), Games(3)
However If I write a single query using all three tables, I get different
results.
The sql is:
SELECT Teams.TID, Count(Games.GID) AS CountOfGID, Count(Players.PID) AS
CountOfPID
FROM (Teams LEFT JOIN Games ON Teams.TID = Games.TID) LEFT JOIN Players ON
Teams.TID = Players.TID
GROUP BY Teams.TID;
I cant figure out what is wrong.
Thanks for any help
Jack
Teams(TID,...)
Players(TID<PID<....)(1:M on teams)
Games(TID<GID<....)(1:M onteams)
I want to write a query that gives me the number of players and number of
games for each team
If I use the group by clause on TID and the count on just one of the tables
, I get the correct counts Players(4), Games(3)
However If I write a single query using all three tables, I get different
results.
The sql is:
SELECT Teams.TID, Count(Games.GID) AS CountOfGID, Count(Players.PID) AS
CountOfPID
FROM (Teams LEFT JOIN Games ON Teams.TID = Games.TID) LEFT JOIN Players ON
Teams.TID = Players.TID
GROUP BY Teams.TID;
I cant figure out what is wrong.
Thanks for any help
Jack