Name: _________________________________
The following queries apply to the Bookbiz database that comes with the Practical SQL Handbook. The relationship diagram can be found on page 47 of the book. Use the database to check your answer.
title) followed by their publishers (pub_name).
Alphabetize the titles. Use SQL1 syntax (join in the WHERE clause).
SELECT title, pub_name FROM titles, publishers WHERE publishers.pub_id = titles.pub_id ORDER BY title;
SELECT title, pub_name FROM titles NATURAL JOIN publishers ORDER BY title;
SELECT title, pub_name
FROM titles, publishers
WHERE type='business'
AND publishers.pub_id = titles.pub_id
ORDER BY title;
ed_lname, ed_fname) and
titles (title) for Anne Ringer's books? Use whichever
join syntax you prefer.
Hint: This joins 5 tables. There should be 4 lines of output involving three
separate editors.
SELECT ed_lname, ed_fname, title
FROM editors NATURAL JOIN titleditors
NATURAL JOIN titles
NATURAL JOIN titleauthors
NATURAL JOIN authors
WHERE au_lname='Ringer' and au_fname='Anne';
ed_id, ed_lname, ed_fname).
Put this in order of the editor who has done the most work (Dennis McCann
has worked on 10 titles), to least (Bernard Samualson has worked on 2).
Note: This requires both a join and a GROUP BY. Altho there is an
equijoin on ed_id, you will have to qualify this field
in both the SELECT clause and the GROUP BY clause, otherwise ASA will
give you an error about lacking a "correlation name".
SELECT COUNT(*), editors.ed_id, ed_lname, ed_fname FROM editors NATURAL JOIN titleditors GROUP BY editors.ed_id, ed_lname, ed_fname ORDER BY COUNT(*) DESC;