[Database class] HW3 answers
Paul S. Wang
pwang at cs.kent.edu
Thu Feb 16 20:38:32 EST 2012
Dear dbclass,
HW3 grading is done.
Here is a set of good answers for HW3:
/*First query*/
SELECT DISTINCT name from student natural join takes
WHERE course_id LIKE 'CS%'
/*Second query*/
SELECT DISTINCT student.ID, student.name FROM student
WHERE student.ID NOT IN
(SELECT DISTINCT ID FROM takes WHERE
((year=2009 AND semester != 'Fall') OR year < 2009));
/*Third query*/
SELECT dept_name, MAX(salary) AS "Highest salary"
FROM instructor GROUP BY dept_name;
/*Forth query*/
SELECT MIN(max) AS 'Lowest Max Salary' FROM
(SELECT MAX(instructor.salary) AS max
FROM instructor group by instructor.dept_name) AS MaxSalary;
--
==============================================================================
Paul S. Wang (王士弘) Email: pwang at cs.kent.edu
Dept. of Computer Science, Kent State U. Tel: (330) 672-9051
Kent, Ohio, USA 44242-0001 http://www.cs.kent.edu/~pwang/
==============================================================================
More information about the Dbclass
mailing list