Sunteți pe pagina 1din 2

Kathmandu University

Department of Computer Science and Engineering


COMP 232 - Lab Assignment

Based upon the database you created in earlier classes, answer the following queries. You are
practicing basic and intermediate SQL.
1. Find the department names of all instructors.
2. Find the names of all instructors in the Computer Science department who have salary
greater than $70,000.
3. Retrieve the names of all instructors, along with their department names and department
building name.
4. “For all instructors in the university who have taught some course, find their names and
the course ID of all courses they taught.”
5. “List the names of instructors along with the the titles of courses that they teach.”
6. “Find the names of all instructors whose salary is greater than at least one instructor in
the Biology department.”
7. “Find the names of all departments whose building name includes the substring
‘Watson’.”
8. Find the name of all instructors in the Physics department in the ascending order and
secondly in descending order.
9. Find the set of all courses taught either in Fall 2009 or in Spring 2010, or both.
10. Find the set of all courses taught in the Fall 2009 as well as in Spring 2010
11. Find all courses taught in the Fall 2009 semester but not in the Spring 2010 semester.
12. Find the total number of instructors who teach a course in the Spring 2010 semester.
13. Find the average salary in each department.
14. Find the number of instructors in each department who teach a course in the Spring 2010
semester.
15. Find the average salary of instructors in those departments where the average salary is
more than $42,000.
16. For each course section offered in 2009, find the average total credits (tot cred) of all
students enrolled in the section, if the section had at least 2 students.
17. Find the total number of (distinct) students who have taken course sections taught by the
instructor with ID 110011.
18. Find the maximum and minimum enrollment across all sections, considering only
sections that had some enrollment, don't worry about those that had no students taking
that section
19. Find all sections that had the maximum enrollment (along with the enrollment), using a
subquery.
20. Find all courses whose identifier starts with the string "CS-1"
21. Update the salary of each instructor to 2 times the number of course sections they have
taught.
22. Display the IDs of all instructors who have never taught a courses.
23. Find the names of all instructors whose salary is greater than at least one instructor in the
Biology department.
24. Find the departments that have the highest average salary.
25. Find all students who have taken all courses offered in the Biology department.

S-ar putea să vă placă și