aving 3 tables with the following sturucture (see image). Write MYSQL code for the following: (1) Which courses (course name, course credits) have been taken by the student with student ID 861103-2438? (2) For students who have registered courses, how many credits has each student taken? In the query result, list student ID, student first name, student last name, and his/her credits. (3) First define a view that gives the student ID, student last name, student first name, and the grade average for each student who has registered courses. Then use the view to find which students have the highest grade average.
Having 3 tables with the following sturucture (see image). Write MYSQL code for the following:
(1) Which courses (course name, course credits) have been taken by the student with student ID
861103-2438?
(2) For students who have registered courses, how many credits has each student taken? In the
query result, list student ID, student first name, student last name, and his/her credits.
(3) First define a view that gives the student ID, student last name, student first name, and the
grade average for each student who has registered courses. Then use the view to find which
students have the highest grade average.
Question:-
Which courses (course name, course credits) have been taken by the student with student ID 861103-2438?
SQL Query:-
SELECT Courses.CourseName, Courses.Credits
FROM Registration
INNER JOIN Courses ON Registration.CourseCode = Courses.CourseCode
WHERE Registration.StudentId = '861103-2438';
Explanation:-
This query joins the Registration and Courses tables on the CourseCode column and selects the course name and course credits from the Courses table where the StudentId in the Registration table matches '861103-2438'.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps