Hi,
I have 2 tables:
Class - ClassID(int), ClassName(varchar)
Student - StudentID(int), ClassID, Age(smallint), Sex(nchar(1)), DateOfJoining(datetime)
I want to write a query that gives me the Top 10 Class which have maximum no. of student joining during the past 6 months. The query should include the following :
ClassName, Count(StudentID), Avg(Age), Avg(Sex)
From the avg(sex) i mean which was the sex which got enrolled more - ie. M or F. All I want is to find out that if in Class A, no of students enrolled were 50 and out of that 30 were Boys, then the end result of the query should be
Name Count Age Sex
ClassA 50 14 M(60%)
.....
ClassR 40 13 F(80%) ---- assuming out of 40, 32 are girls.
and so on....
How do I do this
Thanks.