--Guillaume Couture coug1812 prompt question 1 prompt Select codeaeroport,novol,ville,nom,etat where Aeroport,segmentdevol etat = QC and (codeaeroport=codeaeroportdepart ) order by codeaeroport,novol; -- prompt question 2 prompt Select distinct codeaeroport,novol,ville,nom,etat Aeroport,segmentdevol where etat = QC and ( codeaeroport=codeaeroportdepart or codeaeroport=codeaeroportarrivee ) order by codeaeroport,novol; -- prompt question 3 prompt select novol,count (nosegment) "nb segments" segmentdevol group by novol; -- prompt question 4 prompt select novol,prix classevol c1 where prix >= all (select prix classevol c2 where c1.novol=c2.novol) order by novol; -- prompt question 5 prompt select v1.novol,count (seg1.nosegment) "nb segments" segmentdevol seg1,vol v1 where v1.novol = seg1.novol (+) group by v1.novol order by v1.novol; --
prompt question 6 prompt select a1.codeaeroport aeroport a1 left outer join segmentdevol seg1 on a1.codeaeroport=seg1.codeaeroportdepart group by a1.codeaeroport having count () <= 2 order by a1.codeaeroport; -- prompt question 7 prompt select a1.codeaeroport aeroport a1 left outer join segmentdevol seg1 on a1.codeaeroport=seg1.codeaeroportdepart or a1.codeaeroport=seg1.codeaeroportarrivee group by a1.codeaeroport having count (seg1.codeaeroportdepart)<= 2 and count (seg1.codeaeroportarrivee)<=2 order by a1.codeaeroport; -- prompt question 8 prompt select v1.novol, v1.typedevol vol v1 order by v1.novol having count (seg1.nosegment)>= all ( select count (seg2.nosegment) segmentdevol seg2 group by seg2.novol ) ; -- prompt question 9 prompt select a1.codeaeroport aeroport a1 left outer join segmentdevol seg1 on a1.codeaeroport=seg1.codeaeroportdepart or a1.codeaeroport=seg1.codeaeroportarrivee group by a1.codeaeroport having count (seg1.codeaeroportdepart)<=0 and count (seg1.codeaeroportarrivee)<=0 order by a1.codeaeroport; -- prompt question 10
prompt select v1.novol vol v1, classe c1 having c1.description = Affaires (select c1.description classe c1 where c1.description = Affaires ) group by novol ; -- prompt question 11 prompt drop view fabricant; create view tablefabriquant as select avion a1, vol v1 join avionvol av1 on av1.novol=v1.novol; select a1.nomodele "fabricant",count (v1.novol) "nbdevols" vol v1, avion a1 join avionvol av1 on av1.novol=v1.novol case when a1.nomodele in ( %Boing% ) then Boing and a1.nomodele in ( %Airbus% ) then Airbus and a1.nomodele not in ( %Boing% ) then Autres and a1.nomodele not in ( %Airbus% ) then Autres ; -- prompt question 12 prompt select cv1.novol classevol cv1 having count (cv1.novol)=4 group by cv1.novol; -- prompt question 13 prompt select codeaeroport where aeroport codeaeroport in ( select distinct codeaeroportdepart
segmentdevol union select distinct codeaeroportarrivee segmentdevol ) order by codeaeroport ; -- prompt question 14 prompt select codeaeroport aeroport where codeaeroport in (select codeaeroportarrivee, codeaeroportdepart segmentdevol) ; -- prompt question 15 prompt SQLPlus: Release 11.2.0.2.0 Production on Fri Oct 3 16:34:53 2014 Copyright (c) 1982, 2010, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options début de test-tp2.sql PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed. Création des tables et données drop table Aeroport cascade constraints Table created. drop table Vol cascade constraints Table created. drop table SegmentDeVol cascade constraints Table created. drop table Classe cascade constraints Table created. drop table ClasseVol cascade constraints
Table created. drop table Avion cascade constraints Table created. drop table AvionVol cascade constraints Table created. Insertion des données
Affichage des résultats de tp2.sql question 1 CODEAEROP NOVOL VILLE NOM ETAT --------- ------------------ ---------------------- ---------------------- ---------------------- YQB AC2003 Québec Jean-Lesage QC YUL AC2001 Montréal Trudeau QC YUL AC2002 Montréal Trudeau QC YUL AC2003 Montréal Trudeau QC YUL AC2007 Montréal Trudeau QC question 2 CODEAEROP NOVOL VILLE NOM ETAT --------- ------------------ ---------------------- ---------------------- ---------------------- YQB AC2003 Québec Jean-Lesage QC YUL AC2001 Montréal Trudeau QC YUL AC2002 Montréal Trudeau QC YUL AC2003 Montréal Trudeau QC YUL AC2004 Montréal Trudeau QC YUL AC2007 Montréal Trudeau QC 6 rows selected. question 3 NOVOL nb segments ------------------ ----------- AC2001 2 AC2002 1 AC2003 3 AC2004 1 AC2007 1 question 4
NOVOL PRIX ------------------ ---------- AC2001 1010.02 AC2002 5275.25 AC2003 199.99 AC2006 9999.99 question 5 NOVOL nb segments ------------------ ----------- AC2001 2 AC2002 1 AC2003 3 AC2004 1 AC2005 0 AC2006 0 AC2007 1 7 rows selected. question 6 CODEAEROP --------- CDG JFK YQB YVR YYZ question 7 CODEAEROP --------- YQB YVR question 8 having count (seg1.nosegment)>= all
ERROR at line 4: ORA-00933: SQL command not properly ended question 9 CODEAEROP --------- YVR question 10 (select c1.description ERROR at line 4: ORA-00933: SQL command not properly ended question 11 drop view fabricant create view tablefabriquant as ORA-00957: duplicate column name case ERROR at line 5: ORA-00933: SQL command not properly ended question 12 NOVOL ------------------
AC2001 question 13 CODEAEROP --------- CDG JFK YQB YUL YYZ question 14 (select codeaeroportarrivee, codeaeroportdepart ERROR at line 4: ORA-00913: too many values question 15 Disconnected Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options