0% found this document useful (1 vote)
593 views

Assignment 2b: Nested Subqueries and SQL Updates: Submission Status

The document contains instructions for performing various SQL queries and updates: 1. Find courses without prerequisites by selecting courses not in the prereq table. 2. Find students who haven't taken biology courses by selecting students not associated with biology department courses. 3. Write update queries to: give all instructors a 10% salary hike; increase credits for students who took "Genetics" by the credits for that course; increase salary of instructors advising 2+ students by $50,000; set credits to 2 for courses with less than 5 students total enrolled across sections and years.

Uploaded by

Modi Mitulkumar
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
593 views

Assignment 2b: Nested Subqueries and SQL Updates: Submission Status

The document contains instructions for performing various SQL queries and updates: 1. Find courses without prerequisites by selecting courses not in the prereq table. 2. Find students who haven't taken biology courses by selecting students not associated with biology department courses. 3. Write update queries to: give all instructors a 10% salary hike; increase credits for students who took "Genetics" by the credits for that course; increase salary of instructors advising 2+ students by $50,000; set credits to 2 for courses with less than 5 students total enrolled across sections and years.

Uploaded by

Modi Mitulkumar
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Assignment 2b: Nested Subqueries and SQL Updates

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

You might also like