From f3a325dd19db3db5635e581587fe67e4bfc31b0b Mon Sep 17 00:00:00 2001 From: pvalarcher Date: Thu, 14 Nov 2024 10:01:58 +0100 Subject: [PATCH] corrections TP2 et TP3 --- Code/CorrectionsTP/TP2.sql | 38 +++++++++++++++++++++++++++++ Code/CorrectionsTP/TP3.sql | 49 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 Code/CorrectionsTP/TP2.sql create mode 100644 Code/CorrectionsTP/TP3.sql diff --git a/Code/CorrectionsTP/TP2.sql b/Code/CorrectionsTP/TP2.sql new file mode 100644 index 0000000..1ec4802 --- /dev/null +++ b/Code/CorrectionsTP/TP2.sql @@ -0,0 +1,38 @@ +# Q1 +select * from buveur; + +# Q2 +select numbuveur, nom, ville from buveur ; + +# Q3 +select numbuveur, nom from buveur where ville = 'PARIS'; + +# Q4 +select numbuveur, nom from buveur where ville = 'PARIS' or ville = 'MACON'; + +# Q5 +select cru from vin where region = 'LOIRE' + +select distinct cru from vin where region = 'LOIRE'; + +# Q6 + +select distinct ville from buveur; + +# Q7 +select NumCom from commande where qtte between 10 and 50; +select NumCom from commande where qtte >10 and qtte <50; + +# Q8 +select NumCom, dateliv from livraison where DateLiv > '01/12/1987'; + +# Q9 +select numvin, cru from vin where cru like 'B%'; + +# Q10 +select numvitic, nom from viticulteur where nom like '%LIN%'; + +# Q11 +select numbuveur, nom from buveur where ville != 'PARIS' and ville !='MACON'; +select numbuveur, nom from buveur where ville not in ('PARIS', 'MACON'); + diff --git a/Code/CorrectionsTP/TP3.sql b/Code/CorrectionsTP/TP3.sql new file mode 100644 index 0000000..df01595 --- /dev/null +++ b/Code/CorrectionsTP/TP3.sql @@ -0,0 +1,49 @@ +-- Q1 +select B.numbuveur, nom, ville +from buveur B, Commande C +where B.numbuveur = C.numbuveur; + +select distinct B.numbuveur, nom, ville +from buveur B, Commande C +where B.numbuveur = C.numbuveur; + +select distinct numbuveur, nom, ville +from buveur natural join Commande ; + +select distinct numbuveur, nom, ville +from buveur join Commande using(numbuveur) ; + +select distinct b.numbuveur, nom, ville +from buveur b join Commande c on (b.numbuveur=c.numbuveur); + + +-- Q2 +select distinct numvitic, nom, prenom +from viticulteur natural join vin +where region = 'LOIRE' and millesime = 1983; + +-- Q3 +select distinct B.numbuveur, nom +from buveur b, commande c, vin v +where b.numbuveur = c.numbuveur and c.numvin=v.numvin and cru = 'POMMARD' ; + +select distinct numbuveur, nom +from buveur natural join commande natural join vin +where cru = 'POMMARD'; + +-- Q4 +select distinct nom +from vin v, commande c, viticulteur t +where c.numvin = v.numvin and v.numvitic = t.numvitic and numbuveur = 1600; + +select distinct nom +from commande natural join vin natural join viticulteur +where numbuveur = 1600; + +select distinct nom +from viticulteur +where numvitic in (select numvitic + from vin + where numvin in (select numvin + from commande + where numbuveur = 1600));