Moyenne de count et group by
Bonjour à tous,
Je suis nouveau sur la partie SQL du forum.
J'ai trois tables :Adherents : Id, Qualite, Nom, Prenom, Complement, Batiment, Adresse, Code Postal, Ville, Pays, DateNaissance, DateFede, DateClub, Categorie, DateInscription, TelDom, TelPor, Type
Seances : Id, Nom, DateDebut, DateFin
Participants : IdAdherent, IdSeance, Encadrant
Je cherche à des fins de statistique de faire les moyennes de nombre de participants par séances.
Le nom des séances est toujours identique : Séance du et le nom du jour.
Si je fais :
Code:
1 2 3 4
| Select Seances.nom,
Count(Participants.IdAdherent) as Nbr_Participant
From Seances inner join Participants on Seances.Id = Participants.IdSeance inner join Adherents on Participants.IdAdherent = Adherents.Id
Group by Seances.nom |
J'obtiens :
nom Nbr_Participant
Séance du mardi 7
Séance du mercredi 5
Séance du samedi 4
Séance du vendredi 8
Cependant si je fais :
Code:
1 2 3 4
| Select Seances.nom,
AVG(Count(Participants.IdAdherent)) as Moy_Participant
From Seances inner join Participants on Seances.Id = Participants.IdSeance inner join Adherents on Participants.IdAdherent = Adherents.Id
Group by Seances.nom |
J'obtiens l'erreur : "Msg 130, Niveau 15, État 1, Ligne 2
Cannot perform an aggregate function on an expression containing an aggregate or a subquery."
Merci par avance.
Bonne journée.