Changes between Version 5 and Version 6 of Analytical and statistical querying
- Timestamp:
- 09/30/25 21:48:17 (13 days ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Analytical and statistical querying
v5 v6 1 1 = Analytical and statistical querying = 2 2 3 == dentify At-Risk Students Based on Attendance and Grades (multi-metric scoring system) ==3 == Identify At-Risk Students Based on Attendance and Grades (multi-metric scoring system) == 4 4 5 5 {{{#!sql … … 45 45 }}} 46 46 47 == Find Students Who Attended Less Than 50% of Their Classes==47 == Rolling Average of Assignment Scores per Student == 48 48 49 49 {{{#!sql 50 SELECT 51 s.id_student, 52 u.username, 53 a.id_assignment, 54 sub.progress_score, 55 AVG(sub.progress_score) OVER (PARTITION BY s.id_student ORDER BY sub.submitted_at ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) AS rolling_avg_score 56 FROM Submits sub 57 JOIN Student s ON sub.id_student = s.id_student 58 JOIN User u ON s.id_user = u.id_user 59 JOIN Assignment a ON sub.id_assignment = a.id_assignment 60 ORDER BY s.id_student, sub.submitted_at; 50 61 51 62 }}} 52 63 53 == Find the Most Enrolled Course==64 == Find Classes with Low Attendance and Underperforming Scores == 54 65 55 66 {{{#!sql 67 WITH low_attendance_classes AS ( 68 SELECT 69 a.id_class, 70 COUNT(*) FILTER (WHERE a.attended = TRUE) * 100.0 / COUNT(*) AS attendance_rate 71 FROM Attendance a 72 GROUP BY a.id_class 73 HAVING COUNT(*) > 5 AND COUNT(*) FILTER (WHERE a.attended = TRUE) * 100.0 / COUNT(*) < 60 74 ), 75 low_score_classes AS ( 76 SELECT 77 c.id_class, 78 AVG(sub.progress_score) AS avg_score 79 FROM Course_Class cc 80 JOIN Class c ON cc.id_class = c.id_class 81 JOIN Course_Assignment ca ON cc.id_Course = ca.id_Course 82 JOIN Assignment a ON ca.id_assignment = a.id_assignment 83 JOIN Submits sub ON a.id_assignment = sub.id_assignment 84 GROUP BY c.id_class 85 HAVING AVG(sub.progress_score) < 60 86 ) 87 SELECT DISTINCT 88 la.id_class, 89 cl.start_time, 90 cl.end_time, 91 la.attendance_rate, 92 ls.avg_score 93 FROM low_attendance_classes la 94 JOIN low_score_classes ls ON la.id_class = ls.id_class 95 JOIN Class cl ON cl.id_class = la.id_class; 56 96 57 97 }}} 58 98 59 == Get the Percentage of Students Who Completed a Course==99 == Time Series Report: Avg Score Per Week == 60 100 {{{#!sql 101 SELECT 102 DATE_TRUNC('week', submitted_at) AS week, 103 AVG(progress_score) AS avg_score 104 FROM Submits 105 GROUP BY DATE_TRUNC('week', submitted_at) 106 ORDER BY week; 61 107 62 108 }}} 63 109 64 = Find the Average Progress Score for Each Course, and Compare It to Overall Average=110 == Teacher Effectiveness Score == 65 111 66 112 {{{#!sql 113 WITH teacher_ratings AS ( 114 SELECT 115 id_teacher, 116 AVG(rating) AS avg_rating 117 FROM Rates 118 GROUP BY id_teacher 119 ), 120 teacher_scores AS ( 121 SELECT 122 c.created_by AS id_teacher, 123 AVG(sub.progress_score) AS avg_student_score 124 FROM Course c 125 JOIN Course_Assignment ca ON c.id_Course = ca.id_Course 126 JOIN Assignment a ON ca.id_assignment = a.id_assignment 127 JOIN Submits sub ON sub.id_assignment = a.id_assignment 128 GROUP BY c.created_by 129 ) 130 SELECT 131 t.id_teacher, 132 u.username, 133 r.avg_rating, 134 s.avg_student_score, 135 ROUND((r.avg_rating * 0.5 + s.avg_student_score * 0.5), 2) AS effectiveness_score 136 FROM Teacher t 137 JOIN User u ON t.id_user = u.id_user 138 JOIN teacher_ratings r ON t.id_teacher = r.id_teacher 139 JOIN teacher_scores s ON t.id_teacher = s.id_teacher 140 ORDER BY effectiveness_score DESC; 67 141 68 142 }}} 69 143 70 = Rank Professors by Subject Based on Average Rating=144 == Identify Students with Sharp Score Drop Between Assignments == 71 145 72 146 {{{#!sql 147 WITH score_changes AS ( 148 SELECT 149 id_student, 150 id_assignment, 151 progress_score, 152 progress_score - LAG(progress_score) OVER (PARTITION BY id_student ORDER BY submitted_at) AS score_diff 153 FROM Submits 154 ) 155 SELECT 156 sc.id_student, 157 u.username, 158 sc.id_assignment, 159 sc.progress_score, 160 sc.score_diff 161 FROM score_changes sc 162 JOIN Student s ON sc.id_student = s.id_student 163 JOIN User u ON s.id_user = u.id_user 164 WHERE sc.score_diff < -20 165 ORDER BY sc.score_diff ASC; 73 166 74 167 }}} 75 168 169 == Detect Duplicate Submissions or Possible Cheating Behavior == 76 170 171 {{{#!sql 172 SELECT 173 s1.id_student, 174 s2.id_student AS other_student, 175 a.id_assignment, 176 s1.progress_score, 177 s2.progress_score, 178 ABS(s1.progress_score - s2.progress_score) AS score_diff 179 FROM Submits s1 180 JOIN Submits s2 181 ON s1.id_assignment = s2.id_assignment 182 AND s1.id_student <> s2.id_student 183 AND ABS(s1.progress_score - s2.progress_score) < 1 184 ORDER BY score_diff ASC; 77 185 186 }}}