Below are two sample database tables (directory, attendance). In directory, each
ID: 3809097 • Letter: B
Question
Below are two sample database tables (directory, attendance). In directory, each student is assigned to a teacher. In attendance, each student's tardiness (minutes_late) is recorded per day Using SQL, please craft a query which show for each teacher, how many minutes late have their students been all semester.
Table: directory Table - attendance teacher_id student_id student_id minutes_late 3 1 9 4 0 5 61 2 3 9 41 7 2 13 53 4 3 17 5 7 3 21 61 7 1 25 5 10 3 29 21 2 3 33 37 4 1 37 5 5 2 41 61 4 0 45 65 10 3 49 65 6 3 53 45 6 1 57 21 6 2 61 17 10 2 65 49 7 37 1 9 8 61 1 33 0 5 0 1 9 57 5 9 5 53 3 61 1 17 3 13 9 5 3 17 8 1 3 57 1 17 4 5 0Explanation / Answer
This is query for show how many total minutes late have their students been all semester:
mysql>Select sum(minutes_late),count( student_id) from attendance where student_id=1;
+-------------------+--------------------+
| sum(minutes_late) | count( student_id) |
+-------------------+--------------------+
| 12 | 2 |
+-------------------+--------------------+
1 row in set (0.00 sec)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.