Lab 7.
Subqueries and Set Operations
CS122, Fall 2011
(30pt) Complete the following queries in SQL. Please put your
queries
in an SQL script file lab7.sql
and upload it to CSNS
at the end of the lab. Note
that file uploading will be disabled
automatically after 4:00pm, and late submission will not be accepted.
- Chapter 6, p.161, Exercise 1-5, 7.
- Chapter 5, p.139, Exercise 5. Note that if multiple track titles
are tied for the longest, all of them should be included in the results.
- Complete the following queries without using joins:
- List the names of the sales persons whose supervisors are
supervised by no one.
- List the names of the artists who are located in the same city as a studio.
- Find the number of members who are under the charge of Clint Sanchez or Clint Sanchez's supervisor.
[NOTES]
- Unlike what the textbook says, all queries can be completed
using MySQL 5.
- If a question asks you to use EXISTS, you may use NOT
EXISTS as well.
- For +3 extra credit, write two queries for Exercise 6.4 -
one using group by and one using correlated subqueries without join.