我需要有关此查询的帮助。对于这个问题,我们有两个关于战舰和他们参加的战斗的模式: Ships(name, yearLaunched, country, numGuns, gunSize,displacement) Battles(ship, BattleName, result) 问题如下:写一个查询拥有枪支尺寸第二大的枪支。更准确地说,无论有多少其他船的火炮尺寸比这大一号,找出火炮尺寸仅超过一种火炮尺寸的船只。列出船只的名称和它们的火炮尺寸。我试图解决这个问题,我的答案如下:
Select smax.name, smax.gunSize
From ships smax
Where ((select s.name,s.gunSize
from Ships s
where s.gunSize NOT EXISTS ( select ss.gunSize from ships ss where ss.gunSize >= ALL(select
ss1.gunSize from ships ss1))) AS temp)
AND smax.gunSize >= ALL (select temp.gunSize from ships temp)
感谢您花时间阅读并回答!