I have this query:
SELECT AVG(a.score) AS Average1, AVG(b.score) AS Average2, AVG(c.score) AS Average3
FROM
(SELECT subfactor.score, dateID, EmployeeID
FROM employeescore
LEFT JOIN subfactor
ON employeescore.SubFactorID = subfactor.SubFactorID
LEFT JOIN factor
ON subfactor.FactorID = factor.FactorID
WHERE DateID='Jan2015' AND employeescore.EmployeeID='1' AND subfactor.FactorID='A1')a
OUTER JOIN
(SELECT subfactor.score, DateID, EmployeeID
FROM employeescore
LEFT JOIN subfactor
ON employeescore.SubFactorID = subfactor.SubFactorID
LEFT JOIN factor
ON subfactor.FactorID = factor.FactorID
WHERE DateID='Feb2015' AND employeescore.EmployeeID='1' AND subfactor.FactorID='A1')b
ON a.EmployeeID = b.EmployeeID
OUTER JOIN
(SELECT subfactor.score, DateID, EmployeeID
FROM employeescore
LEFT JOIN subfactor
ON employeescore.SubFactorID = subfactor.SubFactorID
LEFT JOIN factor
ON subfactor.FactorID = factor.FactorID
WHERE DateID='Mar2015' AND employeescore.EmployeeID='1' AND subfactor.FactorID='A1')c
ON b.EmployeeID = c.EmployeeID;
Basically I want to select the averages of the three scores and I want to display the output regardless if one of the joined sub queries doesn't have any records. But I keep getting an error of ('OUTER' is not a valid input for this position). How can I repair?
Aucun commentaire:
Enregistrer un commentaire