Below is my query:
SELECT
UT.AgentName AS [Agent Name],
UT.TeamName AS Team,
Format(Now(),"Short Date") AS [As Of],
Sum(I.RegPointValue) AS Points
FROM
(SELECT
UU.AgentID,
(Nz(UU.LastName,'')+", "+Nz(UU.FirstName,'')) AS AgentName ,
TT.TeamName
FROM
Users AS UU
INNER JOIN
Teams AS TT
ON UU.TeamID = TT.TeamID) AS UT
LEFT JOIN
(InfractionTypes AS I
INNER JOIN
(DateCodes AS D
INNER JOIN
AquiredInfractions AS AI
ON D.DateID = AI.DateID)
ON I.InfractionID = AI.InfractionID)
ON UT.AgentID = AI.AgentID
WHERE (((D.DateValue)>=#4/1/2014#))
GROUP BY UT.TeamName, UT.AgentName, I.RegPointValue;
What this does is sum up all of the points that a person would get depending upon the attendance infractions that they have recieved. If I change the LEFT JOIN
to INNER JOIN
the query works but only returns the names of people that have received attendance infractions. But what I would like is for it to return the names of all people and have 0 for their points if they haven't received any.
The error that I get when I try to save or execute is Join expression not supported
. I have been trying to get this to work for the last few hours by messing with the order of the joins but to no avail. Using MS-Access 2013.
You are missing some aliases.
Every inner query used as a table must be given an alias, and when joining them you must use that alias and only the selected columns on the join condition.
For example, add aliases to these lines:
...
ON D.DateID = AI.DateID) AS SOMETHING_1
ON I.InfractionID = AI.InfractionID) AS SOMETHING_2
etc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.