I need to find the names of aircraft such that all pilots certified to operate them earn more than 60000.
Query I wrote:
select aname
from employee join certified
on employee.eid=certified.eid
join aircraft
on certified.aid=aircraft.aid
where salary>60000;
But it returns aname if there is any pilot with more than 60000 salary,difficult part is that i need to find if all pilots earn more than 60000 only then the aname is displayed.
You can just look for the opposite case - that no pilots earn less than 60,000:
SELECT
aname
FROM
Aircraft A
WHERE
NOT EXISTS
(
SELECT *
FROM Certified C
INNER JOIN Employee E ON
E.eid = C.eid AND
E.salary < 60000
WHERE C.aid = A.aid
)
SELECT aname FROM Aircraft where NOT EXISTS (SELECT eid FROM Employee AS e INNER JOIN Certified AS c ON c.eid=e.eid WHERE salary<60000 AND aid=Aircraft.aid)
从存在飞机的地方选择一个名字(从经过认证的C内联结中选择*雇员E ON e.eid = C.eid和E.salary> 60000 W.E C.aid = A.aid)
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.