Explication :
On va combiner plusieurs tables pour obtenir un résultat complet, en utilisant jointures et regroupements.
Tables utilisées :
Etudiants
| id_etudiant | Nom | Prénom |
| 1 | Claire | Dupont |
| 2 | Julien | Martin |
| 3 | Sophie | Bernard |
👉 Notes
| id_note | id_etudiant | Matière | Note |
| 1 | 1 | Maths | 14 |
| 2 | 1 | Histoire | 15 |
| 3 | 2 | Maths | 12 |
| 4 | 2 | Histoire | 10 |
| 5 | 3 | Maths | 16 |
| 6 | 3 | Histoire | 13 |
Objectif : Afficher le nom et prénom de chaque étudiant avec leur moyenne générale.
SELECT Etudiants.Nom, Etudiants.Prénom, AVG(Notes.Note) AS Moyenne FROM Etudiants, Notes WHERE Etudiants.id_etudiant = Notes.id_etudiant GROUP BY Etudiants.id_etudiant, Etudiants.Nom, Etudiants.Prénom;
Résultat attendu :
| Nom | Prénom | Moyenne |
| Claire | Dupont | 14.5 |
| Julien | Martin | 11 |
| Sophie | Bernard | 14.5 |