Public Function getClass(Result As Integer) As String
Dim str As String
Select Case Result
Case Is > 99
str = "A"
Case Is > 89
str = "B"
Case Is > 79
str = "C"
Case Else
str = "D"
End Select
getClass = str
End Function
假设你要计算数学分等级的人数
SELECT 成绩.班别, getClass([数学]) AS 等级, Count(成绩.数学) AS (数学)人数
FROM 成绩
GROUP BY 成绩.班别, getClass([数学])
ORDER BY 成绩.班别 DESC;