I need to make a query that shows the passenger that has traveled on all the aircraft of the company

0

Be the following relationship schemes:

•   Tramo (Nro-vuelo, Desde, Hasta)

•   Avión_Utilizado (nro-vuelo, tipo-avión, nroavión)

•   Info_pasajeros (nro - vuelo, documento-identidad, nombre, fecha)

This is what I have tried:

SELECT Info_Pasajeros.Nombre
FROM Tramo
INNER JOIN Info_Pasajeros ON Info_Pasajeros.NroVuelo = Tramo.NroVuelo
INNER JOIN Avion_Utilizado ON Avion_Utilizado.NroVuelo = Tramo.NroVuelo
GROUP BY Info_Pasajeros.Nombre
HAVING count(Info_Pasajeros.CodPasajero) = count(Avion_Utilizado.CodAvion)
    
asked by Rodrigo Torrico 19.06.2017 в 19:25
source

1 answer

1

First you need to join the tables Info_pasajeros, Avion_Utilizado with the common item nro-vuelo a join would also work.

then use the function ALL with a subquery , which would be the list of all nroavion

SELECT nombre
  FROM Info_pasajeros, Avion_Utilizado
 WHERE Info_pasajeros.nro-vuelo=Avion_Utilizado.nro-vuelo and
nroavion = ALL 
       (SELECT UNIQUE(nroavion=
          FROM Avión_Utilizado)

references:

link link

    
answered by 19.06.2017 в 20:14