- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
The following relations keep track of airline flight information:
Aircraft (aircraft_number, aircraft_make, cruisingrange)
Certified (pilot_id, aircraft_number)
Pilot (pilot_id, pilot_name, salary)
Note that italic attributes denote primary keys. In this scheme every pilot is certified for some aircraft. Write each of the following queries in SQL Format.
(ii) Find the names of pilots who can operate planes with a range greater than 2,000 miles but are not certified on any Boeing aircraft.
有人可以帮助我了解如何为此编写查询吗?
我的猜测是先join PILOT
到CERTIFIED
,然后join
到AIRCRAFT
,然后GROUP BY PILOT.pilot_id
,但除此之外,我不确定如何过滤 pilot_id
以排除那些至少没有一架飞机且续航里程至少为 2000 且没有飞机的飞机aircraft_make
“波音”?
非常感谢!
最佳答案
应该这样做:
select p.pilot_name
from pilot p
join certified c
on p.pilot_id = c.pilot_id
join aircraft a
on c.aircraft_number = a.aircraft_number
where a.cruisingrange > 2000
and p.pilot_id not in (
select c.pilot_id
from certified c
join aircraft a
on c.aircraft_number = a.aircraft_number
where a.aircraft_make = 'BOEING'
)
group by p.pilot_id
关于mysql - SQL:如何过滤 GROUP BY 之外的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43238964/
我是一名优秀的程序员,十分优秀!