Download as pdf or txt
Download as pdf or txt
You are on page 1of 48

Guide to SQL 9th Edition Pratt

Solutions Manual
Go to download the full and correct content document:
https://testbankfan.com/product/guide-to-sql-9th-edition-pratt-solutions-manual/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Guide to SQL 9th Edition Pratt Test Bank

https://testbankfan.com/product/guide-to-sql-9th-edition-pratt-
test-bank/

Guide To SQL 8th Edition Pratt Test Bank

https://testbankfan.com/product/guide-to-sql-8th-edition-pratt-
test-bank/

A+ Guide to Hardware 9th Edition Andrews Solutions


Manual

https://testbankfan.com/product/a-guide-to-hardware-9th-edition-
andrews-solutions-manual/

Impact A Guide to Business Communication Canadian 9th


Edition Northey Solutions Manual

https://testbankfan.com/product/impact-a-guide-to-business-
communication-canadian-9th-edition-northey-solutions-manual/
A+ Guide to Hardware 9th Edition Andrews Test Bank

https://testbankfan.com/product/a-guide-to-hardware-9th-edition-
andrews-test-bank/

Financial Accounting in an Economic Context 9th Edition


Pratt Solutions Manual

https://testbankfan.com/product/financial-accounting-in-an-
economic-context-9th-edition-pratt-solutions-manual/

A+ Guide to IT Technical Support Hardware and Software


9th Edition Andrews Solutions Manual

https://testbankfan.com/product/a-guide-to-it-technical-support-
hardware-and-software-9th-edition-andrews-solutions-manual/

Seidels Guide To Physical Examination 9th Edition Ball


Test Bank

https://testbankfan.com/product/seidels-guide-to-physical-
examination-9th-edition-ball-test-bank/

Oracle 12C SQL 3rd Edition Casteel Solutions Manual

https://testbankfan.com/product/oracle-12c-sql-3rd-edition-
casteel-solutions-manual/
A Guide to SQL, Ninth Edition Solutions 5-1

Chapter 5: Multiple-Table Queries

Solutions

Answers to Review Questions

1. Indicate in the SELECT clause all columns to display, list in the FROM clause all
tables to join, and then include in the WHERE clause any conditions requiring values
in matching columns to be equal.
2. You must qualify names if the same name appears in more than one of the tables listed
in the FROM clause. You qualify column names using the following format: table
name.column name.
3. IN and EXISTS.
4. Nested subqueries refers to a subquery within a subquery. The innermost subquery is
executed first.
5. An alias is an alternate name for a table. To specify one in SQL, follow the name of the
table with the name of the alias. You use the alias just like a table name throughout the
SQL command.
6. List the table twice in the FROM clause, using two different aliases. Use these aliases
in both the SELECT clause and in the condition in the WHERE clause that relates the
tables.
7. Use the UNION, INTERSECT, and MINUS operators to create a union, intersection,
and difference of two tables. To perform any of these operations, the tables must be
union-compatible.
8. Two tables are union-compatible if they have the same number of columns and if their
corresponding columns have identical data types and lengths.
9. If a subquery is preceded by the ALL operator, the condition is true only if it is
satisfied by all values produced by the subquery.
10. If a subquery is preceded by the ANY operator, the condition is true if it is satisfied
by any value (one or more) produced by the subquery.
11. In an inner join, only matching rows from both tables are included. You can use the
INNER JOIN clause to perform an inner join.
12. In a left outer join, all rows from the left table (that is, the first table listed) are
included whether or not they match (that is, satisfy the matching condition in the
WHERE clause). Only matching rows from the right table are included. You can use
the LEFT JOIN clause to perform a left outer join.
13. In a right outer join, all rows from the table on the right will be included regardless of
whether they match rows from the table on the left. Rows from the table on the left
A Guide to SQL, Ninth Edition Solutions 5-2

will be included only if they match. You can use the RIGHT JOIN clause to perform a
right outer join.
14. The formal name is Cartesian product. To form a product of two tables, include both
tables in the FROM clause and omit the WHERE clause.
15. [Critical Thinking] Answers will vary. Answers should note that an equi-join is
similar to an inner join except that both matching columns appear in the results. A
natural join is the same as the inner join discussed in this chapter. A cross join is the
same as a Cartesian product.
16. [Critical Thinking] Answers will vary. Answers should mention that cost-based query
optimizers assign an estimated "cost" to each possible query execution plan, and
choose the execution plan with the smallest cost. Queries that join three or more tables
benefit from a cost-based query optimizer.

Answers to TAL Distributors Exercises

1.
SELECT ORDER_NUM, ORDER_DATE, ORDERS.CUSTOMER_NUM, CUSTOMER_NAME
FROM ORDERS, CUSTOMER
WHERE ORDERS.CUSTOMER_NUM = CUSTOMER.CUSTOMER_NUM;

2.
In Oracle and SQL Server, the command is:
SELECT ORDER_NUM, ORDERS.CUSTOMER_NUM, CUSTOMER_NAME
FROM ORDERS, CUSTOMER
WHERE ORDERS.CUSTOMER_NUM = CUSTOMER.CUSTOMER_NUM
AND ORDER_DATE = '10/15/2015';

In Access, the command is:


SELECT ORDER_NUM, ORDERS.CUSTOMER_NUM, CUSTOMER_NAME
FROM ORDERS, CUSTOMER
WHERE ORDERS.CUSTOMER_NUM = CUSTOMER.CUSTOMER_NUM
AND ORDER_DATE = #10/15/2015#;
A Guide to SQL, Ninth Edition Solutions 5-3

3.
SELECT ORDERS.ORDER_NUM, ORDER_DATE, ITEM_NUM, NUM_ORDERED, QUOTED_PRICE
FROM ORDERS, ORDER_LINE
WHERE ORDERS.ORDER_NUM = ORDER_LINE.ORDER_NUM;

4.
In Oracle and SQL Server, the command is:
SELECT CUSTOMER_NUM, CUSTOMER_NAME
FROM CUSTOMER
WHERE CUSTOMER_NUM IN
(SELECT CUSTOMER_NUM
FROM ORDERS
WHERE ORDER_DATE = ‘10/15/2015’);

In Access, the command is:


SELECT CUSTOMER_NUM, CUSTOMER_NAME
FROM CUSTOMER
WHERE CUSTOMER_NUM IN
(SELECT CUSTOMER_NUM
FROM ORDERS
WHERE ORDER_DATE = #10/15/20150#);

5.
In Oracle and SQL Server, the command is:
SELECT CUSTOMER_NUM, CUSTOMER_NAME
FROM CUSTOMER
WHERE EXISTS
(SELECT *
FROM ORDERS
WHERE ORDERS.CUSTOMER_NUM = CUSTOMER.CUSTOMER_NUM
AND ORDER_DATE = '10/15/2015');

In Access, the command is:


A Guide to SQL, Ninth Edition Solutions 5-4

SELECT CUSTOMER_NUM, CUSTOMER_NAME


FROM CUSTOMER
WHERE EXISTS
(SELECT *
FROM ORDERS
WHERE ORDERS.CUSTOMER_NUM = CUSTOMER.CUSTOMER_NUM
AND ORDER_DATE = #10/15/2015#);

6.
In Oracle and SQL Server, the command is:
SELECT CUSTOMER_NUM, CUSTOMER_NAME
FROM CUSTOMER
WHERE CUSTOMER_NUM NOT IN
(SELECT CUSTOMER_NUM
FROM ORDERS
WHERE ORDER_DATE = '10/15/2015');

In Access, the command is:


SELECT CUSTOMER_NUM, CUSTOMER_NAME
FROM CUSTOMER
WHERE CUSTOMER_NUM NOT IN
(SELECT CUSTOMER_NUM
FROM ORDERS
WHERE ORDER_DATE = #10/15/2015#);

7.
SELECT ORDERS.ORDER_NUM, ORDER_DATE, ITEM.ITEM_NUM, DESCRIPTION, CATEGORY
FROM ORDERS, ORDER_LINE, ITEM
WHERE ORDERS.ORDER_NUM = ORDER_LINE.ORDER_NUM
AND ORDER_LINE.ITEM_NUM = ITEM.ITEM_NUM;
A Guide to SQL, Ninth Edition Solutions 5-5

8.
SELECT ORDERS.ORDER_NUM, ORDER_DATE, ITEM.ITEM_NUM, DESCRIPTION, CATEGORY
FROM ORDERS, ORDER_LINE, ITEM
WHERE ORDERS.ORDER_NUM = ORDER_LINE.ORDER_NUM
AND ORDER_LINE.ITEM_NUM = ITEM.ITEM_NUM
ORDER BY CATEGORY, ORDERS.ORDER_NUM;

9.
SELECT REP_NUM, LAST_NAME, FIRST_NAME
FROM REP
WHERE REP_NUM IN
(SELECT REP_NUM
FROM CUSTOMER
WHERE CREDIT_LIMIT = 10000);
A Guide to SQL, Ninth Edition Solutions 5-6

10.
SELECT DISTINCT REP.REP_NUM, LAST_NAME, FIRST_NAME
FROM REP, CUSTOMER
WHERE REP.REP_NUM = CUSTOMER.REP_NUM
AND CREDIT_LIMIT = 10000;

11.
SELECT CUSTOMER.CUSTOMER_NUM, CUSTOMER_NAME
FROM CUSTOMER, ORDERS, ORDER_LINE, ITEM
WHERE CUSTOMER.CUSTOMER_NUM = ORDERS.CUSTOMER_NUM
AND ORDERS.ORDER_NUM = ORDER_LINE.ORDER_NUM
AND ORDER_LINE.ITEM_NUM = ITEM.ITEM_NUM
AND DESCRIPTION = 'Rocking Horse';

12.
SELECT F.ITEM_NUM, F.DESCRIPTION, S.ITEM_NUM, S.DESCRIPTION, F.CATEGORY
FROM ITEM F, ITEM S
WHERE F.CATEGORY = S.CATEGORY
AND F.ITEM_NUM < S.ITEM_NUM
ORDER BY CATEGORY, F.ITEM_NUM, S.ITEM_NUM;
A Guide to SQL, Ninth Edition Solutions 5-7

13.
SELECT ORDERS.ORDER_NUM, ORDER_DATE
FROM CUSTOMER, ORDERS
WHERE CUSTOMER.CUSTOMER_NUM = ORDERS.CUSTOMER_NUM
AND CUSTOMER_NAME = 'Johnson''s Department Store';

14.
A Guide to SQL, Ninth Edition Solutions 5-8

SELECT ORDERS.ORDER_NUM, ORDER_DATE


FROM ORDERS, ORDER_LINE, ITEM
WHERE ORDERS.ORDER_NUM = ORDER_LINE.ORDER_NUM
AND ORDER_LINE.ITEM_NUM = ITEM.ITEM_NUM
AND DESCRIPTION = 'Fire Engine';

15.
SELECT ORDER_NUM, ORDER_DATE
FROM CUSTOMER, ORDERS
WHERE CUSTOMER.CUSTOMER_NUM = ORDERS.CUSTOMER_NUM
AND CUSTOMER_NAME = 'Almondton General Store'
UNION
SELECT ORDERS.ORDER_NUM, ORDER_DATE
FROM ORDERS, ORDER_LINE, ITEM
WHERE ORDERS.ORDER_NUM = ORDER_LINE.ORDER_NUM
AND ORDER_LINE.ITEM_NUM = ITEM.ITEM_NUM
AND DESCRIPTION = 'Fire Engine';

16.
SELECT ORDER_NUM, ORDER_DATE
FROM CUSTOMER, ORDERS
WHERE CUSTOMER.CUSTOMER_NUM = ORDERS.CUSTOMER_NUM
AND CUSTOMER_NAME = 'Almondton General Store'
AND ORDER_NUM IN
(SELECT ORDER_NUM
FROM ORDER_LINE, ITEM
WHERE ORDER_LINE.ITEM_NUM = ITEM.ITEM_NUM
AND DESCRIPTION = 'Fire Engine');

17.
SELECT ORDER_NUM, ORDER_DATE
FROM CUSTOMER, ORDERS
WHERE CUSTOMER.CUSTOMER_NUM = ORDERS.CUSTOMER_NUM
AND CUSTOMER_NAME = 'Almondton General Store'
AND ORDER_NUM NOT IN
(SELECT ORDER_NUM
FROM ORDER_LINE, ITEM
WHERE ORDER_LINE.ITEM_NUM = ITEM.ITEM_NUM
AND DESCRIPTION = 'Fire Engine');

18.
SELECT ITEM_NUM, DESCRIPTION, PRICE, CATEGORY
FROM ITEM
WHERE PRICE > ALL
(SELECT PRICE
FROM ITEM
WHERE CATEGORY = 'GME');
A Guide to SQL, Ninth Edition Solutions 5-9

19.
SELECT ITEM.ITEM_NUM, DESCRIPTION, ON_HAND, NUM_ORDERED
FROM ITEM
LEFT JOIN ORDER_LINE
ON ITEM.ITEM_NUM = ORDER_LINE.ITEM_NUM
ORDER BY ITEM.ITEM_NUM;

20. [Critical Thinking]


SELECT ITEM_NUM, DESCRIPTION, PRICE, CATEGORY
FROM ITEM
WHERE PRICE > ANY
(SELECT PRICE
FROM ITEM
WHERE CATEGORY = 'GME');

This query answers the question “Which items have a price greater than any price in the category GME?”
21. [Critical Thinking]
SELECT CUSTOMER_NUM, CUSTOMER_NAME, LAST_NAME, FIRST_NAME
FROM CUSTOMER
RIGHT JOIN REP
ON REP.REP_NUM = CUSTOMER.REP_NUM
ORDER BY REP.REP_NUM;

OR

SELECT CUSTOMER_NUM, CUSTOMER_NAME, LAST_NAME, FIRST_NAME


FROM REP
A Guide to SQL, Ninth Edition Solutions 5-10

LEFT JOIN CUSTOMER


ON REP.REP_NUM = CUSTOMER.REP_NUM
ORDER BY REP.REP_NUM;

Answers to Colonial Adventure Tours Exercises

1.
SELECT RESERVATION_ID, TRIP_ID, RESERVATION.CUSTOMER_NUM, LAST_NAME
FROM RESERVATION, CUSTOMER
WHERE RESERVATION.CUSTOMER_NUM = CUSTOMER.CUSTOMER_NUM
ORDER BY LAST_NAME;
A Guide to SQL, Ninth Edition Solutions 5-11

2.
SELECT RESERVATION_ID, TRIP_ID, NUM_PERSONS
FROM RESERVATION, CUSTOMER
WHERE RESERVATION.CUSTOMER_NUM = CUSTOMER.CUSTOMER_NUM
AND LAST_NAME = 'Goff'
AND FIRST_NAME = 'Ryan';

3.
SELECT TRIP_NAME
FROM TRIP, GUIDE, TRIP_GUIDES
WHERE TRIP.TRIP_ID = TRIP_GUIDES.TRIP_ID
AND GUIDE.GUIDE_NUM = TRIP_GUIDES.GUIDE_NUM
AND LAST_NAME = 'Abrams'
A Guide to SQL, Ninth Edition Solutions 5-12

AND FIRST_NAME = 'Miles';

4.
SELECT TRIP_NAME
FROM TRIP, GUIDE, TRIP_GUIDES
WHERE TRIP.TRIP_ID = TRIP_GUIDES.TRIP_ID
AND GUIDE.GUIDE_NUM = TRIP_GUIDES.GUIDE_NUM
AND LAST_NAME = 'Boyers'
AND FIRST_NAME = 'Rita'
AND TYPE = 'Biking';

5.
In Oracle and SQL Server, the command is:
SELECT LAST_NAME, TRIP_NAME, START_LOCATION
FROM TRIP, CUSTOMER, RESERVATION
WHERE TRIP.TRIP_ID = RESERVATION.TRIP_ID
AND RESERVATION.CUSTOMER_NUM = CUSTOMER.CUSTOMER_NUM
AND TRIP_DATE = '7/23/2016';

In Access, the command is:


SELECT LAST_NAME, TRIP_NAME, START_LOCATION
FROM TRIP, CUSTOMER, RESERVATION
WHERE TRIP.TRIP_ID = RESERVATION.TRIP_ID
AND RESERVATION.CUSTOMER_NUM = CUSTOMER.CUSTOMER_NUM
AND TRIP_DATE = #7/23/2016#;

6.
SELECT RESERVATION_ID, TRIP_ID, TRIP_DATE
FROM RESERVATION
WHERE TRIP_ID IN
(SELECT TRIP_ID
FROM TRIP
WHERE STATE = 'ME');

7.
A Guide to SQL, Ninth Edition Solutions 5-13

SELECT RESERVATION_ID, TRIP_ID, TRIP_DATE


FROM RESERVATION
WHERE EXISTS
(SELECT *
FROM TRIP
WHERE TRIP.TRIP_ID = RESERVATION.TRIP_ID
AND STATE = 'ME');

Note: These are the same results but in a different order. To list the reservations in reservation ID order, use
the ORDER BY RESERVATION_ID clause at the end of the SQL command.
8.
SELECT LAST_NAME, FIRST_NAME
FROM GUIDE, TRIP, TRIP_GUIDES
WHERE TRIP.TRIP_ID = TRIP_GUIDES.TRIP_ID
AND GUIDE.GUIDE_NUM = TRIP_GUIDES.GUIDE_NUM
AND TYPE = 'Paddling';

9.
SELECT LAST_NAME, FIRST_NAME
FROM GUIDE G, TRIP T, TRIP_GUIDES TG
WHERE T.TRIP_ID = TG.TRIP_ID
AND G.GUIDE_NUM = TG.GUIDE_NUM
AND TYPE = 'Paddling';
A Guide to SQL, Ninth Edition Solutions 5-14

10.
SELECT F.TRIP_ID, F.TRIP_NAME, S.TRIP_ID, S.TRIP_NAME, F.START_LOCATION
FROM TRIP F, TRIP S
WHERE F.START_LOCATION = S.START_LOCATION
AND F.TRIP_ID < S.TRIP_ID
ORDER BY F.TRIP_ID, S.TRIP_ID;

11.
SELECT TRIP_NAME
FROM RESERVATION, TRIP
WHERE RESERVATION.TRIP_ID = TRIP.TRIP_ID
AND TYPE = 'Hiking'
ORDER BY TRIP_NAME;
A Guide to SQL, Ninth Edition Solutions 5-15

12.
SELECT CUSTOMER_NUM, LAST_NAME
FROM CUSTOMER
WHERE STATE = 'NJ'
UNION
SELECT CUSTOMER.CUSTOMER_NUM, LAST_NAME
FROM RESERVATION, CUSTOMER
WHERE RESERVATION.CUSTOMER_NUM = CUSTOMER.CUSTOMER_NUM;
A Guide to SQL, Ninth Edition Solutions 5-16

13.
SELECT CUSTOMER_NUM, LAST_NAME
FROM CUSTOMER
WHERE STATE = 'NJ'
INTERSECT
SELECT CUSTOMER.CUSTOMER_NUM, LAST_NAME
FROM RESERVATION, CUSTOMER
WHERE RESERVATION.CUSTOMER_NUM = CUSTOMER.CUSTOMER_NUM;

14.
SELECT TRIP_ID, TRIP_NAME
FROM TRIP
WHERE MAX_GRP_SIZE > ALL
(SELECT MAX_GRP_SIZE
FROM TRIP
WHERE TYPE = 'Hiking');

15.
SELECT TRIP_ID, TRIP_NAME
FROM TRIP
WHERE MAX_GRP_SIZE > ANY
(SELECT MAX_GRP_SIZE
FROM TRIP
WHERE TYPE = 'Biking');
A Guide to SQL, Ninth Edition Solutions 5-17

16.
SELECT TRIP.TRIP_ID, TRIP_NAME, RESERVATION_ID
FROM TRIP
LEFT JOIN RESERVATION
ON TRIP.TRIP_ID = RESERVATION.TRIP_ID
ORDER BY TRIP.TRIP_ID;
A Guide to SQL, Ninth Edition Solutions 5-18
A Guide to SQL, Ninth Edition Solutions 5-19

17. [Critical Thinking]


SELECT DISTINCT(LAST_NAME), FIRST_NAME
FROM GUIDE, TRIP, TRIP_GUIDES
WHERE TRIP.TRIP_ID = TRIP_GUIDES.TRIP_ID
AND GUIDE.GUIDE_NUM = TRIP_GUIDES.GUIDE_NUM
AND TYPE = 'Paddling'
ORDER BY LAST_NAME;
A Guide to SQL, Ninth Edition Solutions 5-20

18. [Critical Thinking]


SELECT DISTINCT(TRIP_NAME)
FROM RESERVATION, TRIP
WHERE RESERVATION.TRIP_ID = TRIP.TRIP_ID
AND TYPE = 'Hiking'
AND STATE = 'NH'
ORDER BY TRIP_NAME DESC;

Answers to Solmaris Condominium Group Exercises


1.
SELECT LOCATION_NUM, UNIT_NUM, CONDO_FEE, CONDO_UNIT.OWNER_NUM,
FIRST_NAME, LAST_NAME
FROM CONDO_UNIT, OWNER
WHERE CONDO_UNIT.OWNER_NUM = OWNER.OWNER_NUM;

2.
SELECT CONDO_ID, DESCRIPTION, STATUS
FROM SERVICE_REQUEST, SERVICE_CATEGORY
WHERE SERVICE_REQUEST.CATEGORY_NUM = SERVICE_CATEGORY.CATEGORY_NUM
AND CATEGORY_DESCRIPTION = 'Janitorial';
A Guide to SQL, Ninth Edition Solutions 5-21

3.
SELECT SERVICE_REQUEST.CONDO_ID, LOCATION_NUM, UNIT_NUM, EST_HOURS,
SPENT_HOURS, CONDO_UNIT.OWNER_NUM, LAST_NAME
FROM SERVICE_REQUEST, SERVICE_CATEGORY, CONDO_UNIT, OWNER
WHERE SERVICE_REQUEST.CATEGORY_NUM = SERVICE_CATEGORY.CATEGORY_NUM
AND SERVICE_REQUEST.CONDO_ID = CONDO_UNIT.CONDO_ID
AND CONDO_UNIT.OWNER_NUM = OWNER.OWNER_NUM
AND CATEGORY_DESCRIPTION = 'Janitorial';

4.
SELECT FIRST_NAME, LAST_NAME
FROM OWNER
WHERE OWNER_NUM IN
(SELECT OWNER_NUM
FROM CONDO_UNIT
WHERE BDRMS = 3);

5.
SELECT FIRST_NAME, LAST_NAME
FROM OWNER
WHERE EXISTS
(SELECT *
FROM CONDO_UNIT
WHERE CONDO_UNIT.OWNER_NUM = OWNER.OWNER_NUM
AND BDRMS = 3);

6.
SELECT F.UNIT_NUM, S.UNIT_NUM
FROM CONDO_UNIT F, CONDO_UNIT S
WHERE F.SQR_FT = S.SQR_FT
AND F.UNIT_NUM < S.UNIT_NUM
ORDER BY F.UNIT_NUM, S.UNIT_NUM;
A Guide to SQL, Ninth Edition Solutions 5-22

7.
SELECT SQR_FT, CONDO_UNIT.OWNER_NUM, LAST_NAME, FIRST_NAME
FROM CONDO_UNIT, OWNER
WHERE CONDO_UNIT.OWNER_NUM = OWNER.OWNER_NUM
AND LOCATION_NUM = '1';

8.
SELECT SQR_FT, CONDO_UNIT.OWNER_NUM, LAST_NAME, FIRST_NAME
FROM CONDO_UNIT, OWNER
WHERE CONDO_UNIT.OWNER_NUM = OWNER.OWNER_NUM
AND LOCATION_NUM = '1'
AND BDRMS = 3;

9.
SELECT LOCATION_NUM, UNIT_NUM, CONDO_FEE
FROM CONDO_UNIT, OWNER
WHERE CONDO_UNIT.OWNER_NUM = OWNER.OWNER_NUM
AND CITY = 'Bowton'
UNION
SELECT LOCATION_NUM, UNIT_NUM, CONDO_FEE
FROM CONDO_UNIT
WHERE BDRMS = 1;

10.
SELECT LOCATION_NUM, UNIT_NUM, CONDO_FEE
FROM CONDO_UNIT, OWNER
WHERE CONDO_UNIT.OWNER_NUM = OWNER.OWNER_NUM
AND CITY = 'Bowton'
AND LOCATION_NUM IN
(SELECT LOCATION_NUM
FROM CONDO_UNIT
WHERE BDRMS = 1);
A Guide to SQL, Ninth Edition Solutions 5-23

11.
SELECT LOCATION_NUM, UNIT_NUM, CONDO_FEE
FROM CONDO_UNIT, OWNER
WHERE CONDO_UNIT.OWNER_NUM = OWNER.OWNER_NUM
AND CITY = 'Bowton'
AND LOCATION_NUM NOT IN
(SELECT LOCATION_NUM
FROM CONDO_UNIT
WHERE BDRMS = 1);
No data found

12.
SELECT SERVICE_ID, CONDO_ID
FROM SERVICE_REQUEST
WHERE EST_HOURS > ANY
(SELECT EST_HOURS
FROM SERVICE_REQUEST
WHERE CATEGORY_NUM = 5);

13.
SELECT SERVICE_ID, CONDO_ID
FROM SERVICE_REQUEST
WHERE EST_HOURS > ALL
(SELECT EST_HOURS
FROM SERVICE_REQUEST
WHERE CATEGORY_NUM = 5);

14.
SELECT CONDO_UNIT.CONDO_ID, SQR_FT, OWNER_NUM, SERVICE_ID,
EST_HOURS, SPENT_HOURS
FROM CONDO_UNIT, SERVICE_REQUEST
WHERE CONDO_UNIT.CONDO_ID = SERVICE_REQUEST.CONDO_ID
AND CATEGORY_NUM = 4;
A Guide to SQL, Ninth Edition Solutions 5-24

15.
SELECT CONDO_UNIT.CONDO_ID, SQR_FT, OWNER_NUM, SERVICE_ID,
EST_HOURS, SPENT_HOURS
FROM CONDO_UNIT
LEFT JOIN SERVICE_REQUEST
ON CONDO_UNIT.CONDO_ID = SERVICE_REQUEST.CONDO_ID
AND CATEGORY_NUM = 4;

16. [Critical Thinking]


SELECT CONDO_UNIT.CONDO_ID, SQR_FT, OWNER_NUM, SERVICE_ID,
EST_HOURS, SPENT_HOURS
FROM SERVICE_REQUEST
RIGHT JOIN CONDO_UNIT
ON CONDO_UNIT.CONDO_ID = SERVICE_REQUEST.CONDO_ID
AND CATEGORY_NUM = 4;

Exercise 15 uses a left outer join and and Exercise 16 uses a right outer join. Both
commands retrieve rows that do not match. The difference occurs in which table you list
first.
Another random document with
no related content on Scribd:
See brudder’s funny face, baby?
Slim
[Coming out, and speaking with boundless contempt.]
Dat’s de last time I tackle a job along wit’ a fambly man!
Bessie
Bill, yuh promised us a Christmas tree!
Pete
An’ we knowed yuh’d get us one!
Annie
Yuh said yuh was gonna get one, didn’t yuh, Bill?
Maggie
So we folleyed yuh all de way—
Pete
Yuh couldn’t lose us, Bill!
Annie
Not on yer life!
Pete
We wanted dat tree!
T’eodore
[A grand climax.]
An’ here it is!
[There is a chorus of delighted screams as the children
surround the tree.]
Bessie
Bill, what a peach of a tree!
Pete
Some tree!
Annie
Lookit de presents!
T’eodore
Golly, lookit de presents!
Maggie
See de boo-ful tree, baby?
[She makes the baby clap its hands.]
David
[Puzzled, as the children, shrilling their delight, descend
upon the gifts.]
Say, Santa Claus, I didn’t know you had a family.
Slim
[With infinite disgust.]
Kid, yuh said a mout’ful!
David
Are they all related to you?
Bill
[Not too modestly.]
Me eight brudders an’ sisters—count ’em. Bessie—an’ Pete—dey’re
twins. An’ Maggie—dat’s her holdin’ de baby—an’ T’eodore—an’
Annie—an’ Grover—an’ Woodrow—an’ Calvin—dat’s de baby.
David
Do they all come from the North Pole?
Bessie
[With injured American pride.]
W’at do yuh t’ink? We’re a lot of Polanders?
Bill
De Nort’ Pole? De Nort’ Pole’s warm next to w’ere dey come from.
My paw ain’t woikin’, an’ de landlord toined off de heat w’en I didn’t
pay de rent.
David
Rent? What’s rent?
Slim
[As Bill gazes appealingly at him.]
Yuh started dis. Yuh tell him.
Bill
Rent? Rent’s somethin’ yuh pay w’en yuh get money.
David
And when you don’t get it?
Bill
Yuh don’t.
Slim
[Becoming impatient.]
Say, what I wanna know is dis: is dis a kidnapin’ party, or is dis a kid
party?
David
What’s a kidnaping party, Santa Claus?
Bill
I’ll show yuh.
[He calls to the children.]
Hey, fellers, we’re gonna beat it.
Pete
Naw!
Bessie
We don’t wanna go, Bill.
Annie
We wanna play wit’ de presents!
T’eodore
Lookit de sleds!
Pete
An’ de boxin’ gloves!
Annie
An’ de railroad trains!
Bessie
An’ de trumpets!
Maggie
See de pretty flowers, baby?
Pete
[Parceling out the musical instruments.]
Yuh take dis—and yuh take dis—an’ w’en I say “Ready,” yuh all blow
to onct.
Slim
[Anxiously.]
Nuttin’ doin’!
Pete
Ready!
[The din is terrific.]
David
[Indicating the instruments with some anxiety, and pulling
Bill’s sleeve.]
Santa Claus, they haven’t been boiled!
Slim
W’at?
David
They haven’t been boiled, Mr. Slim!
Slim
[And you know he means the children—not the toys.]
Dey oughta be!
Pete
All ready? Go!
[The uproar is repeated.]
Slim
[To Bill.]
An’ I told yuh not to make a sound!
Bill
Say, kid, dere ain’t nobody else on dis floor, is dere?
David
No—nobody but us.
Bill
[Drawing a sigh of relief.]
Dat’s good. Now, fellers, we’re gonna go—
Slim
[Interrupting.]
An’ we’re gonna take him—
[He indicates David.]
along with us.
Bessie
W’at’s de hurry, Bill?
Pete
We don’t wanna go!
T’eodore
Not now!
Bessie
Bill, dere’s no place fer us to go to.
Bill
W’at do yuh mean?
Pete
De landlord, he come along w’ile we was leavin’, an’ he says we
needn’t come back—none of us—never.
Bessie
[Rather pleased with her news.]
He says he’ll put de furniture on de sidewalk, an’ yuh can git it
w’enever yuh like.
Pete
De sooner de better, he says.
Bessie
Yea—an’ dat wasn’t all he says!
Bill
[Aghast.]
He trun yuh out de moment my back was toined?
Bessie
Yuh bet he did!
Bill
He trun yuh out? He trun yuh out?
Bessie
Dat’s w’at I’m tellin’ yuh.
Bill
An’ what did paw say?
Bessie
Paw says ef yuh can’t support him in better style den dat, he’s gonna
quit yuh cold.
Bill
W’at do yuh t’ink of dat, Slim? Ain’t it de limit? Ain’t dat de absoloot
limit?
David
[Seizing Bill’s hand.]
What’s the matter, Santa Claus?
Bill
[Angrily.]
Aw, nuttin’!
David
Why don’t you tell me, Santa Claus?
Bill
[Bitterly.]
Dere’s nuttin’ de matter—on’y de kids ain’t gonna have a roof over
deir heads to-night!
David
Because you didn’t get money?
Bill
Dat’s w’y.
David
And because you didn’t pay the rent?
Bill
Yuh said it, kid.
David
But why do you want a roof over their heads? Can’t we take them
along with us?
Bill
W’at’s dat?
David
They can come to the North Pole too, can’t they? Of course it will be
a little crowded in the sleigh, but there’ll be room for all of us if we sit
close. And we’ll have lots of fun!
Slim
[Meaningly.]
Do yuh hear dat, Bill?
David
[Eagerly.]
The reindeer are waiting outside!
Slim
Aroun’ de corner.
David
Dancer and Prancer, and Blixen and Vixen—
Bill
[Interrupting.]
De reindeer’s name is Lizzie—an’ her radiator’s froze.
Slim
[Crossing to him earnestly.]
But it’s gonna get us away from here, Bill! We get outa de city—we
go somew’eres in de Bronx—an’ den we give Millman a ring on de
telephone—
David
Don’t telephone daddy; he’s always busy.
Slim
He won’t be busy dis time.
[He argues with Bill.]
David
You don’t know my daddy! My daddy is the busiest man in the world!
When he comes to see me, he says, “Exactly ten”—and that means
exactly ten. When I want to see him I have to ask his secretary—and
sometimes he can’t see me at all.
Bessie
Do yuh like dat?
David
I don’t like it—but I guess daddy has to work.
Bessie
Your daddy woik? W’at fer?
David
I guess he wants his money—so that he can pay his rent.
[Bessie snickers. David bridles indignantly.]
Don’t make fun of him! I won’t let anybody do that! I don’t think
anybody works as hard as he works! Why, he starts in the morning
before I get up, and sometimes when I wake in the middle of the
night, I tiptoe to the door of my room, and I can see the light burning
in his study downstairs! Daddy works hard—and he looks so tired!
He’s so tired sometimes that he won’t let me sit in his lap.
Bessie
My daddy lets me sit in his lap all I like!
David
[Eagerly.]
Does everybody call him a fine man?
Bessie
[A bit dubiously.]
Dey calls him all sorts of t’ings—but he don’t mind dat.
David
Do the policemen stop and speak to him?
Bessie
Not ef he sees dem foist.
David
Do they send men to his house to take his picture?
Bessie
[With pardonable pride.]
Dey don’t have ter: dey got his pitcher at headquarters.
Bill
[Who has been arguing with Slim in undertones during the
preceding dialogue, now turns abruptly.]
Come on, fellers! We’re gonna go!
[Slim takes David’s hand.]
A Chorus
Naw, Bill!... We wanna play wit’ de presents!... We don’t wanna leave
de presents!... We want de presents!
Bill
[Angrily.]
Come on, I say!
Maggie
[Appealingly.]
Baby don’t wanna leave de presents!
David
Santa Claus, let them take the presents with them!
[As Slim releases him in astonishment, he runs to the
children.]
Here: you take this, and here’s something for you; and you take one
of the railroad trains—don’t forget the tracks—and you take the other
one.
Bill
[Dumbfounded.]
Yuh’re givin’ away yer toys?
David
[Busy distributing gifts.]
They want them more than I do!
[He turns again to the children.]
Here: you can carry more than that!
[Annie’s arms are full already, but he piles toys on the
heap.]
Put these on top. Take them along.
[To Pete.]
Do they let you ride a bicycle?
Pete
Sure t’ing!
David
Then take this one.
[To Bessie.]
Do they let you go coasting on a sled?
Bessie
All I want—ef I gotta sled.
David
Here’s one for you.
[To T’eodore, holding up a pair of boxing gloves.]
Can you use them?
T’eodore
Kin a duck swim?
David
Take them.
Pete
[To Bill.]
Hey, Bill, can I have de tennis racket?
Bill
[To David.]
How about it?
David
[And you see it hurts—and besides Pete’s arms are full.]
He wants it more than I do.
Maggie
[With a cry of delight.]
Gee, look w’at I found! Ice skates! See de ice skates, baby?
David
Ice skates!
[He pauses; takes them in his hand; caresses them. This
time it hurts very much indeed.]
Bill
[Almost savagely.]
W’at are yuh gonna do, kid?
David
[Smiling at Bill.]
I’m going to give them to her.
[He places them in Maggie’s hands.]
Take good care of them—and look out for the baby—they’re sharp.
[He turns to Bill.]
And now, Santa Claus, what’s a kidnaping party?
Bill
Yuh wanna know dat?
David
Yes, Santa Claus!
Bill
Yuh really wanna know?
[David takes his hand and nods eagerly. Bill hesitates.
Then he glares defiantly at Slim, and turns to David.]
Kid, yuh ain’t never gonna loin dat from me!
Slim
[With hostility.]
W’at did yuh say?
David
[Apologetically.]
I didn’t mean to forget your present, Mr. Slim.
[He runs to the tree and fetches the candy.]
Here you are! And Merry Christmas!
[He gives Slim the box.]
Slim
De candy! Dat’s my idee of one fine present!
David
And now, Santa Claus?
Bill
[Shaking his head.]
Kid, it’s gonna cost me a lotta coin—an’ gee, w’at wouldn’t I do wit’
just a coupla dollars?—but youse a little gen’leman—see?—an’ ef
anybody lays a finger on yuh, I’ll moider him!
[He casts a defiant glance at Slim, and claps his arm upon
David’s shoulders in a rough accolade.]
Kid, youse a good sport—
[He bows grotesquely.]
—an’ I take me hat off to yuh! Yours truly, John W. Santa.
Slim
[Gasping.]
Youse gonna leave him here?
Bill
Yuh hoid me.
Slim
But we come here to—
Bill
[Interrupting.]
I changed my mind—see? A guy dat’s a he-man can do dat little t’ing
—an’ John W. Santa’s a he-man!
[He indicates David.]
I’m gonna leave him here—an’ me an’ de kids is gonna beat it—an’
youse is comin’ along, too; don’t yuh forget dat!
Slim
Bill! Yuh said yuh was hard-boiled!
Bill
[Crossing to him menacingly.]
Ef yuh don’t believe it, now’s de time to try me!
[He pauses.]
Well?
[There is a sudden loud knocking at the locked door at the
right.]
Halligan
[Outside.]
Let me in! Let me in or I’ll break down the door!
Slim
Beat it!
[There is a rush for the windows, but it stops short as the
door at the left, which has been ajar for some
moments, suddenly opens, and Millman stands on
the threshold.]
Bill
[Rising nobly to the occasion.]
A-choo!
David
God bless you!
Slim
We’re pinched!
Millman
[Quietly.]
Just that.
Slim
[Jerking his thumb toward the window.]
Cops outside?
Millman
[Nodding.]
They saw you come in. They’ve been waiting for you to come out.
Annie
[Beginning to cry.]
I want my presents!
Halligan
[Hammering at the door again.]
Let me in!
Millman
Let him in.
[Bill crosses to the door and unlocks it. Halligan and
Vicky, both wabbly, but on their feet again, come into
the room.]
Vicky
Master David! Master David! They haven’t hurt you, have they?
[She rushes to him.]
David
Santa Claus wouldn’t hurt anybody. He was going to give me a
kidnaping party, that was all.
[He pats Bill’s hand.]
Vicky
[Horrified.]
Master David!
Halligan
[Producing a whistle.]
Shall I whistle for the police, sir?
Millman
Wait, Halligan.
[He turns to the intruders.]
The house is surrounded. There is no way you can get out.
Bill
[Most unhappily.]
Yes, sir.
[He takes off his mask. For the first time we see his face:
the face of a half-starved lad with big eyes.]
Millman
Bear that in mind.
[Most unaccountably, most leisurely, he turns his back on
Bill, and draws up a chair.]
Davy, how would you like to sit in my lap?
David
I’d love it, Daddy!
Millman
So would I.
[David rushes to him. Millman settles him comfortably,
quite oblivious of the others.]
There. There. David, where were you going with this man?
David
Not “this man,” Daddy: it’s Santa Claus.
Millman
I meant Santa Claus.
David
I was just going to the North Pole.
Millman
Were you going to leave me alone?
David
I would have come back to-morrow or the next day, Daddy—if you
wanted me.
Millman
[Eloquently.]
If I wanted you!
[He pauses.]
Are you sure you would have come back, Davy?
David
Well, pretty sure.
[He hesitates.]
I wouldn’t want to bother you if you were busy.
Millman
[Wincing.]
I’m not so busy as you think, Davy.
David
No?
Millman
No.
[He pauses.]
Sometimes, when a man’s lonely—when he misses somebody who’s
gone terribly, terribly much—he tries to make himself busy. Do you
understand that, Davy?
David
I think I do. You mean—Mummy.
Millman
I mean—Mummy.
[His voice lightens.]
But now that my little boy is growing older, I don’t expect to be nearly
so busy any more.
David
[Ecstatically.]
Really, Daddy?
Millman
Honest and truly!
David
[Turning to Bill.]
Did you hear that, Santa Claus?
[Bill shuffles his feet and does not answer.]
Millman
[Sharply.]
Did you hear that, Santa Claus?
Bill
Yes, sir. I hoid him.
Millman
[Trying to speak lightly.]
And now, if you still want to go to the North Pole with Santa Claus—
you may go.
[He pauses.]
Do you want to go?
David
[Hesitates; rises; looks at his father; looks at Bill—and
then, to his father’s unutterable horror, runs to Bill.]
You won’t mind, will you, Santa Claus?
[Bill is silent.]
Millman
[In a tone like that of a whiplash.]
Answer him!
Bill
[Addressing David, and exceedingly gruff.]
W’at do yuh mean, kid?
David
You won’t mind if I stay here, will you? I don’t care so much about
that old North Pole.

You might also like