SELECT Output.name, Output.avgSalary
FROM (SELECT Airplane.aid, Airplane.aname AS name,
AVG (worker.salary) AS avgSalary
FROM Aircraft Airplane , Certified IsCertified, Employees worker
WHERE Airplane.aid = IsCertified.aid AND
IsCertified.eid = worker.eid AND
Airplane.crusingrange > 1000
GROUP BY Airplane.aid, Airplane.aname) AS Output
Oracle SQL says error at "AS Output" near the end, yet I cannot figure out what is wrong with it. :S
ERROR at line 1:
ORA-00933: SQL command not properly ended
You don't need a subselect. This query is equivalent:
SELECT
Airplane.aname AS name,
AVG(worker.salary) AS avgSalary
FROM Aircraft Airplane
JOIN Certified IsCertified ON Airplane.aid = IsCertified.aid
JOIN Employees worker ON IsCertified.eid = worker.eid
WHERE Airplane.crusingrange > 1000
GROUP BY Airplane.aid, Airplane.aname
try this:
SELECT Airplane.aid, Airplane.aname AS name,
AVG (worker.salary) AS avgSalary
FROM Aircraft Airplane INNER JOIN Certified IsCertified on
Airplane.aid = IsCertified.aid
INNER JOIN Employees worker on IsCertified.eid = worker.eid
WHERE Airplane.crusingrange > 1000
GROUP BY Airplane.aid, Airplane.aname
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.