Part 1
1

Chapter 6 :
Regrouper : GROUP BY

Exemple sur les regroupements : Example SQL n°2

The questions should help you understand the code shown below.
Once you hold the solution, you can view the answer by clicking on the question title.

1.Quelles sont les colonnes affichées grâce à cette requête ?

R : Le nom des films et pour chaque film la somme des durées de location.

2.Quelle instruction a permis de calculer la durée de location ?

R : SUM(Duree)

3.Quelle instruction a permis regrouper ce calcul pour chaque film

R : GROUP BY FILMS.CodeFilm
Validated example
SELECT nomfilm, SUM(Locations.DUREE) as 'Nombre de jour de location par film' 
FROM Locations 
INNER JOIN Films
    ON Films.codefilm=Locations.codefilm 
Group BY Films.codefilm;
Table Clients (codecli, prenomcli, nomcli, ruecli, cpcli, villecli)
Primary key : codecli

Table Films (codefilm, nomfilm)
Primary key : codefilm

Table Locations (codecli, codefilm, datedebut, duree)
Primary key : codecli, codefilm
Foreign key : codefilm of the table Films, codecli of the table Clients

Request 1
nomfilm
Nombre de jour de location par film
C'est arrivé près de chez vous
3
Bernie
9
Intouchables
3
Ong Bak
3
Shoot' Em UP
2
Tigres et dragons
1
Matrix 1
2
Machete
4
2 / 2
Exemple sur les regroupements