Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select E.codEmp, count(*) as contagem, Num_Aeroportos.quantidade
- from Empresa E, (select voo.CodEmp, Visitados.Aeroportos_Cobertos
- from Voo voo, Rota rota, (select Voo.CodEmp, Rota.Origem as Aeroportos_Cobertos
- from Rota, Voo
- where Voo.CodVoo = Rota.CodVoo
- union
- select Voo.CodEmp, Rota.Destino
- from Rota, Voo
- where Voo.CodVoo = Rota.CodVoo) as Visitados
- where voo.CodVoo = rota.CodVoo
- and voo.CodEmp = Visitados.CodEmp
- group by voo.CodEmp, Visitados.Aeroportos_Cobertos) as TTTT, (select COUNT(*) as quantidade
- from (select Rota.Origem as Aeroportos_Cobertos
- from Rota
- union
- select Rota.Destino
- from Rota, Voo) as TT) as Num_Aeroportos
- where E.codEmp = TTTT.codEmp
- group by E.codEmp, Num_Aeroportos.quantidade
- having count(*) = Num_Aeroportos.quantidade
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement