-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmysql.sql
More file actions
36 lines (31 loc) · 1.12 KB
/
mysql.sql
File metadata and controls
36 lines (31 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
SELECT *
FROM grades;
-- Finding averages... --
SELECT grades_course_id, AVG(grades_value)
FROM grades
GROUP BY grades_course_id;
-- The top grades for each student --
SELECT students_name, grades_value, MAX(grades_value)
FROM grades
INNER JOIN students
ON grades.grades_students_id = students.students_id
GROUP BY grades_students_id;
-- group students by the courses that they are enrolled in --
SELECT grades_course_id, COUNT(grades_students_id)
FROM grades
GROUP BY grades_course_id;
-- Create a summary report of courses and their average grades,
-- sorted by the most challenging course (course with the lowest average grade) to the easiest course (may have errors)
SELECT courses_id, courses_level
FROM courses
INNER JOIN grades
ON courses.courses_id = grades.grades_id
WHERE AVG(grades_value);
-- Finding which student and professor have the most courses in common (may have errors)
SELECT students_name, professors_name, COUNT(courses_id)
FROM grades
JOIN students
ON student.students_id = grades.grades_students_id
JOIN professors
ON professors.professors_id = course.courses_professors_id
GROUP BY students_name, professors_name;