Write SQL queries for the following: -Retrieve the names of students enrolled in
ID: 3914125 • Letter: W
Question
Write SQL queries for the following:
-Retrieve the names of students enrolled in the ‘Database Management’ class during the ‘Spr 2017’ term.
-Retrieve the total number of students in the GRADEBOOK database.
-Retrieve the last names of all students whose last name contains the pattern “fe”.
-Retrieve the Sid values of students who have/had enrolled in ‘CSCI130’ and ‘CSCI230’.
-Retrieve the names of students who have not enrolled in any class.
reign keys CATALOG STUDENTS CNO CSCI130 Programming 1 CSCI230 Programming 2 CSCI360 Database Management FNAME LNAME MINIT SID 123456789 Tom Brady 333445555 Jerry Seinfeld A 999999999 Doug Heffernan C COURSES ENROLLS SEC NO CNO Fall 2016 Spr 2017 Spr 2017 SID 123456789 Fall 2016 123456789 Spr 2017 333445555 Fall 2016 333445555 Spr 2017 333445555 Spr 2017 SEC_NO 1 1 1 1 2 1 CSCI130 90 80 70 60 1 CSCI230 90 80 70 60 2 CSCI360 90 80 70 60 1:06 PM TinyPic -. Assignm... Assignm... SQL CO. 7/4/2018Explanation / Answer
1.
SELECT SID FROM ENROLLS E
JOIN COURSES C ON
E.TERM = C.TERM AND E.SEC_NO = C.SEC_NO
WHERE C.CNO = (SELECT CNO FROM CATALOG WHERE CTITLE = 'Database Management') AND C.TERM = 'Spr 2017';
2.
SELECT count(SID) from STUDENTS;
3.
SELECT LNAME
FROM STUDENTS
WHERE LNAME LIKE '*fe*';
4.
SELECT SID
FROM ENROLLS E
JOIN COURSES C
ON E.TERM = C.TERM
WHERE C.CNO IN (‘CSCI130','CSCI230');
5.
SELECT SID
FROM STUDENTS
WHERE SID NOT IN (SELECT SID FROM ENROLLS);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.