Consider the following database and answer the questions below. a) Write the SQL statement the displays the names of the students who have enrolled in the Database Systems course b) Write the SQL statement that displays a list of the students whose names start with ‘S’ c) Write the SQL statement that displays the Student ID, Student Name, Course ID, and Grade for students that passed at least one course with a grade better than B+ (i.e. A-, A, and A+) d) Write the SQL statement that displays the total number of credit hours for the courses enrolled in by the student with ID 1313.
Expert Answer
Hi,
Please find below the queries for the question-
Ans a) SELECT ST_NAME FROM STUDENT S JOIN
ENROLLMENT E ON S.ST_ID=E.ST_ID
JOIN COURSE C
ON E.COURSE_ID=C.COURSE_ID
AND COURSE_TITLE=’Database Systems’;
Ans b) SELECT ST_NAME FROM STUDENT WHERE SUBSTR(ST_NAME,1,1)=’S’;
Ans c) SELECT S.ST_ID, ST_NAME,C.COURSE_ID,E.GRADE
FROM STUDENT S JOIN
ENROLLMENT E ON S.ST_ID=E.ST_ID
JOIN COURSE C
ON E.COURSE_ID=C.COURSE_ID
AND E.GRADE IN(‘A-‘,’A’,’A+’);
Ans d) SELECT S.ST_ID, SUM(CREDIT_HR) AS TOTAL_CREDIT_HOURS
FROM STUDENT S JOIN
ENROLLMENT E ON S.ST_ID=E.ST_ID
JOIN COURSE C
ON E.COURSE_ID=C.COURSE_ID
AND S.ST_ID=’1313′