This document contains SQL queries and their explanations. It begins with 14 queries (RQ1 through RQ14) involving tables like Client, Facture, Article, Commande, Paiement. The queries select, filter, group and join data from these tables. It also provides the full SQL syntax for inner joins and joins using commas. The document is part of a database course taught in 2001-2002 and provides exercises and more can be found on the listed website.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
26 views
Correction ByMiin02FeZ
This document contains SQL queries and their explanations. It begins with 14 queries (RQ1 through RQ14) involving tables like Client, Facture, Article, Commande, Paiement. The queries select, filter, group and join data from these tables. It also provides the full SQL syntax for inner joins and joins using commas. The document is part of a database course taught in 2001-2002 and provides exercises and more can be found on the listed website.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5
Didier DONSEZ, UJF - Bases de Donnes - Anne 2001-2002 5/9
Corrig du TD de Bases de Donnes
Concepteur: Didier DONSEZ. RQ1: SELECT Client.* FROM Client; RQ2: SELECT Client.Nom FROM Client; RQ3: SELECT Client.Nom, Client.Ville FROM Client WHERE (((Client.Ville)="PARIS")); RQ4: SELECT Client.Nom, Client.Ville FROM Client WHERE (((Client.Nom) Like "D*")) OR (((Client.Ville)="PARIS")); RQ5: SELECT Client.Nom, Client.Ville FROM Client WHERE (((Client.Nom) Like "D*") AND ((Client.Ville)="PARIS")); RQ6: SELECT Facture.NoFact, Client.Nom FROM Client INNER JOIN Facture ON Client.NoClient = Facture.NoClient; Plus d'exercices chez : www.ExerciceGratuit.com Didier DONSEZ, UJF - Bases de Donnes - Anne 2001-2002 6/9 SELECT Facture.NoFact, Client.Nom FROM Client, Facture WHERE Client.NoClient = Facture.NoClient; RQ7: SELECT Client.Nom, Article.Libell FROM (Client INNER JOIN Facture ON Client.NoClient = Facture.NoClient) INNER JOIN (Article INNER JOIN Commande ON Article.RefArt = Commande.RefArt) ON Facture.NoFact = Commande.NoFact ORDER BY Client.Nom; SELECT Client.Nom, Article.Libell FROM Client,Facture,Article,Commande WHERE Client.NoClient = Facture.NoClient AND Facture.NoFact = Commande.NoFact AND Article.RefArt = Commande.RefArt ORDER BY Client.Nom; RQ8: SELECT Article.Libell, [Article]![PU]*(1+[Article]![TVA]/100) AS PUTTC FROM Article; Didier DONSEZ, UJF - Bases de Donnes - Anne 2001-2002 7/9 RQ9: SELECT Sum(Commande.Qt*Article.PU) AS CAHT FROM Facture, Article, Commande WHERE Article.RefArt = Commande.RefArt AND Facture.NoFact = Commande.NoFact AND ((Facture.Date>1/2/98)); RQ10: SELECT Client.Nom, Article.Libell, Sum(Commande.Qt) AS SommeDeQt FROM (Client INNER JOIN Facture ON Client.NoClient = Facture.NoClient) INNER JOIN (Article INNER JOIN Commande ON Article.RefArt = Commande.RefArt) ON Facture.NoFact = Commande.NoFact GROUP BY Client.Nom, Article.Libell; SELECT Client.Nom, Article.Libell, Sum(Commande.Qt) AS SommeDeQt FROM Client, Facture, Article,Commande WHERE Client.NoClient = Facture.NoClient AND Facture.NoFact = Commande.NoFact AND Article.RefArt = Commande.RefArt GROUP BY Client.Nom, Article.Libell; RQ11: SELECT Commande.NoFact, Sum([Article]![PU]*(1+[Article]![TVA]/100)*[Commande]![Qt]) AS MontantTotal FROM Article INNER JOIN Commande ON Article.RefArt = Commande.RefArt GROUP BY Commande.NoFact; SELECT Commande.NoFact, Sum([Article]![PU]*(1+[Article]![TVA]/100)*[Commande]![Qt]) AS MontantTotal FROM Article,Commande WHERE Article.RefArt = Commande.RefArt GROUP BY Commande.NoFact; Plus d'exercices chez : www.ExerciceGratuit.com Didier DONSEZ, UJF - Bases de Donnes - Anne 2001-2002 8/9 RQ12 : SELECT Paiement.NoFact, Sum(Paiement.Paiement) AS SommeDePaiement FROM Paiement GROUP BY Paiement.NoFact; RQ13: SELECT Paiement.NoFact, Sum(Paiement.Paiement) AS SommeDePaiement FROM Paiement GROUP BY Paiement.NoFact; RQ13: SELECT RQ11.NoFact, [RQ11]![MontantTotal]-[RQ12]![SommeDePaiement] AS Reste_a_Payer FROM RQ11 INNER JOIN RQ12 ON RQ11.NoFact = RQ12.NoFact; SELECT RQ11.NoFact, [RQ11]![MontantTotal]-[RQ12]![SommeDePaiement] AS Reste_a_Payer FROM RQ11, RQ12 WHERE RQ11.NoFact = RQ12.NoFact; Didier DONSEZ, UJF - Bases de Donnes - Anne 2001-2002 9/9 RQ14: SELECT Client.Nom, Client_1.Nom, Client.Ville FROM Client AS Client_1 INNER JOIN Client ON Client_1.Ville = Client.Ville WHERE (((Client.Nom)>[Client_1].[Nom])) ORDER BY Client.Nom, Client_1.Nom; SELECT Client.Nom, Client_1.Nom, Client.Ville FROM Client AS Client_1,Client WHERE (((Client.Nom)>[Client_1].[Nom])) AND Client_1.Ville = Client.Ville ORDER BY Client.Nom, Client_1.Nom; Plus d'exercices chez : www.ExerciceGratuit.com