Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. select E.codEmp, count(*) as contagem, Num_Aeroportos.quantidade
  2. from Empresa E, (select voo.CodEmp, Visitados.Aeroportos_Cobertos
  3. from Voo voo, Rota rota, (select Voo.CodEmp, Rota.Origem as Aeroportos_Cobertos
  4. from Rota, Voo
  5. where Voo.CodVoo = Rota.CodVoo
  6. union
  7. select Voo.CodEmp, Rota.Destino
  8. from Rota, Voo
  9. where Voo.CodVoo = Rota.CodVoo) as Visitados
  10. where voo.CodVoo = rota.CodVoo
  11. and voo.CodEmp = Visitados.CodEmp
  12. group by voo.CodEmp, Visitados.Aeroportos_Cobertos) as TTTT, (select COUNT(*) as quantidade
  13. from (select Rota.Origem as Aeroportos_Cobertos
  14. from Rota
  15. union
  16. select Rota.Destino
  17. from Rota, Voo) as TT) as Num_Aeroportos
  18. where E.codEmp = TTTT.codEmp
  19. group by E.codEmp, Num_Aeroportos.quantidade
  20. having count(*) = Num_Aeroportos.quantidade
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement