Advanced SQL
CS340 · Chapter 7
1
NULLs and three-valued logic, nested and correlated subqueries (IN, ANY/ALL, EXISTS, UNIQUE), joins (inner, natural, outer, multiway), aggregation, GROUP BY and HAVING, views, schema changes with DROP and ALTER, and running queries from Java with JDBC.
Which finds employees with no supervisor?
Correct: WHERE Super_ssn IS NULL.
Salary > ALL (SELECT Salary FROM EMPLOYEE WHERE Dno = 5) finds employees who earn:
Correct: More than everyone in department 5.
Asked in a real exam
Find employees who have no dependents.
SELECT Fname, Lname FROM EMPLOYEE E WHERE NOT EXISTS (SELECT * FROM DEPENDENT D WHERE D.Essn = E.Ssn);
List all employees, with their department name if they have one:
Correct: EMPLOYEE LEFT OUTER JOIN DEPARTMENT.
COUNT(Super_ssn) on a table where 2 of 8 rows have NULL Super_ssn returns:
Correct: 6.
Asked in a real exam
Departments with more than 5 employees:
Correct: GROUP BY Dno HAVING COUNT(*) > 5.
Asked in a real exam
Asked in a real exam
Remove the foreign-key constraint fk_publisher from BOOK:
Correct: ALTER TABLE BOOK DROP CONSTRAINT fk_publisher;.
No slides match this filter.