I am seeking help with creating a query that will return the total number of classes, total number of classes broken down by age group, total number of participants for each class and total number of participants for each class broken down by age group. I seem to have everything except the total number of participants broken down by age group. I have it to where it returns the total number of children but it doesn't list the correct number of children for each class, it just lists the correct number of children for the first class and then repeats the same number for the rest of the classes.
I'm sure i'm going about the number of participants part all wrong. Please help me if you can.
Thanks
I'm sure i'm going about the number of participants part all wrong. Please help me if you can.
Thanks
Code:
[LEFT]SELECT ClassName,
Count(ClassName) AS [Total # of Classes],
Count(IIf(AgeOfParticipants=1,1,0)) AS [# for Children],
Count(IIf(AgeOfParticipants=2,1,0)) AS [# for Youth],
Count(IIf(AgeOfParticipants=3,1,0)) AS [# for Adults],
Sum(NumberOfParticipants) AS [Total # of Participants], [/LEFT]
[LEFT](SELECT SUM(NumberOfParticipants)
FROM ClassEvaluation
WHERE AgeofParticipants=1) AS [# of Children]
FROM ClassEvaluation[/LEFT]
[LEFT]GROUP BY ClassName;[/LEFT]