Assignment 2b: Nested Subqueries and SQL Updates: Submission Status
Assignment 2b: Nested Subqueries and SQL Updates: Submission Status
1. Find the id and title of all courses which do not require any prerequisites. Select course.course_id,title from course where course.course_id not in(select prereq.course_id from prereq); 2. Find the names of students who have not taken any biology dept courses select distinct name from student,takes,course,department where student.id=takes.id and takes.course_id=course.course_id and course.dept_name=department.dept_name and department.dept_name!='Biology'; 3. Write SQL update queries to perform the following (queries 2 and 4 are pretty meangless, but still fun to write): 1. Give a 10% hike to all instructors update instructor set salary=salary+salary*0.10; 2. Increase the tot_creds of all students who have taken the course titled "Genetics" by the number of credits associated with that course. update student set tot_cred=tot_cred+4 where student.id in(select takes.id from takes where takes.course_id in (select course.course_id from course where title='Genetics')); 3. For all instructors who are advisors of atleast 2 students, increase their salary by 50000. update instructor set salary=salary+50000 where instructor.id in(select instructor.id from instructor,advisor,student where instructor.id=advisor.i_id and advisor.s_id=student.id group by instructor.id having count(student.id)>=2); 4. Set the credits to 2 for all courses which have less than 5 students taking them (across all sections for the course, across all years/semesters). update course set credits=2 where course.course_id in(select takes.course_id from takes where takes.id in (select student.id from student group by student.id having count(student.id)<5));
Submission status
Submission status Grading status Due date Time remaining Nothing has been submitted for this assignment Not graded Friday, 24 May 2013, 10:00 AM 1 day 18 hours