Sql 带分组的MS访问等级GPA
我已经接近找到一个分组排名的答案,但还不完全。我有两张桌子 组织表Sql 带分组的MS访问等级GPA,sql,ms-access,group-by,rank,Sql,Ms Access,Group By,Rank,我已经接近找到一个分组排名的答案,但还不完全。我有两张桌子 组织表 Chapter Council DDD IFC DT IFC GG IFC AA MGC BB MGC CC MGC DD IND EE IND 排班 Chapter GRDPoints TakeGPA MemberName Status DDD 2.0 2 Bill Active DT
Chapter Council
DDD IFC
DT IFC
GG IFC
AA MGC
BB MGC
CC MGC
DD IND
EE IND
排班
Chapter GRDPoints TakeGPA MemberName Status
DDD 2.0 2 Bill Active
DT 3.2 3 Jim New Member
GG 4.0 6 Sue New Member
AA 2.3 6 Jill Active
BB 1.3 5 Joe New Member
CC 3.2 5 Frank Active
DD 3.2 4 Leslie Active
EE 4.0 3 Sandra Active
我必须计算每一章的平均成绩,然后根据委员会对它们进行排名和分组。我没有问题计算GPA,然后再进行子查询以获得其他值,但我似乎无法让排名起作用。下面是我的SQL。我错过了什么让理事会对GPA进行排名
SELECT
Org.Council,
Org.Chapter,
Round((Sum(PSRoster.GrdPoints)/Sum(PSRoster.TakeGPA)),3) AS [Chapter Average],
(
Select Round((Sum(PSRoster.GrdPoints)/Sum(PSRoster.TakeGPA)),3) AS [Chapter Average]
FROM Org INNER JOIN PSRoster ON Org.Chapter = PSRoster.Chapter
WHERE PSRoster.Status = 'Active'
) AS [Active Avg GPA],
(
Select Round((Sum(PSRoster.GrdPoints)/Sum(PSRoster.TakeGPA)),3) AS [Chapter Average]
FROM Org
INNER JOIN PSRoster ON Org.Chapter = PSRoster.Chapter
WHERE PSRoster.Status = 'New Member'
) AS [New Member Avg GPA],
(
SELECT COUNT(PSRoster.Semester) AS [Total Number of 4]
FROM PSRoster
WHERE (PSRoster.Semester = 4.00 ) And Org.Chapter = PSRoster.Chapter
) AS [FourOs]
FROM Org INNER JOIN PSRoster ON Org.Chapter = PSRoster.Chapter
Group By Org.Council, Org.Chapter;
我不能在聚合函数中进行计数。