This commit is contained in:
biss committed 2026-08-11 18:41:30 +08:00
1 parent 5157bb7ebe
commit ea97843f5b
2 files changed
+10 -7

No files matched your search

@@ -61,19 +61,20 @@ public sealed class ClickHouseAnalyticsController(
GROUP BY attendanceDate ORDER BY attendanceDate
""", cancellationToken);
var grades = await client.QueryAsync($"""
SELECT academicTermId, academicTermName, studentCount,
round(weightedScore / nullIf(studentCount, 0), 2) AS averageScore,
round(passedCount / nullIf(studentCount, 0), 4) AS passRate
SELECT academicTermId, academicTermName,
totalStudentCount AS studentCount,
round(totalWeightedScore / nullIf(totalStudentCount, 0), 2) AS averageScore,
round(totalPassedCount / nullIf(totalStudentCount, 0), 4) AS passRate
FROM
(
SELECT academicTermId, any(academicTermName) AS academicTermName,
sum(studentCount) AS studentCount,
sum(averageScore * studentCount) AS weightedScore,
sum(passedCount) AS passedCount
sum(studentCount) AS totalStudentCount,
sum(averageScore * studentCount) AS totalWeightedScore,
sum(passedCount) AS totalPassedCount
FROM {options.Database}.gradeStatistics FINAL
WHERE 1 = 1{collegeFilter}
GROUP BY academicTermId
)
) AS gradeTotals
ORDER BY academicTermName
""", cancellationToken);