Академический Документы
Профессиональный Документы
Культура Документы
5. What is a primary key? List the primary key for each table in the Henry Books database shown in Chapter 1?
The primary key is the column or collection of columns that uniquely identifies a given row.
Branch
BranchNum
Publisher
PublisherCode
Book
BookCode
Author
AuthorNum
Wrote
Inventory
CustomerNum
CustomerName
148
Al's Appliance and Sport
524
Kline's
842
All Season
7. List the number and name of all customers that are represented by sales rep 65 and that have a credit limit of
$10,000.
CustomerNum
CustomerName
462
Bargains Galore
608
Johnson's Department Store
CustCount
4
9. Find the total of the balances for all customers represented by sales rep 35.
SumOfBalance
$8,815.75
10. List the item class and the sum of the value of parts on hand. Group the results by item class.
Class
AP
HW
SG
Value
$22,999.28
$7,495.35
$48,282.75
Chapter 3 Questions
1. What is the purpose of the Where clause in SQL? Which comparison operators can you use in a Where
clause?
The WHERE clause lets you specify a condition. Only those rows on which a condition is satisfied will be included in the
query results. The comparison operators you can include in a WHERE clause are: = (equal to), > (greater than), < (less than),
>= (greater than or equal to), <= (less than or equal to), and < > (not equal to).
2. How do you use the LIKE and IN operators in an SQL query?
To use the LIKE or IN operators in an SQL query, include them in the WHERE clause. A character string containing one or
more wildcards is included after the word LIKE. The word IN is followed by a list of values. 1. What is a computed
field? How can you use one in an SQL query? How so you assign a name to a computed field?
A computed field is one whose values are calculated from other fields. To use one in an SQL query, type the desired
calculation. To assign a name to a computed field, follow the calculation with the word AS and then the desired name.
3. What is a computed field? How can you use one in an SQL query? How do you assign a name to a computed
field?
A computed field is one whose values are calculated from other fields. To use one in an SQL query, type the desired
calculation. To assign a name to a computed field, follow the calculation with the word AS and then the desired name.
5. How do you group data in SQL? When you group data in SQL, are there any restrictions on the items that you
can include in the SELECT clause? Explain.
To group data in SQL, include the words GROUP BY followed by the field or fields on which the data is to be grouped in the
query results. If you group data, you only can include the fields on which you are grouping or statistics in the SELECT
clause.
Regarding the Premiere Products database White the SQL to obtain the following question.
6. List the complete Orders table
SELECT Orders.*
FROM Orders;
7. List the number and name of all customers that are represented by sales rep 35 and that have credit limits of
$5,000.
SELECT Customer.CustomerNum, Customer.CustomerName
FROM Customer
WHERE (Customer.RepNum="35") AND (Customer.CreditLimit=5000;
8. List the number and name of all customers represented by Richard Hull.
9. Create a new table named Sports to contain the columns PartNum, Description, OnHand, Warehouse, and
Price for all rows in which the item class is SG.
SELECT Part.PartNum, Part.Description, Part.OnHand, Part.Warehouse, Part.Price
INTO Sports
FROM Part
WHERE (Part.Class)="SG");
10. In the Part table, change the description of part AT94 to Flat Iron.
UPDATE part
SET part.Description = " Flat Iron "
WHERE (part.PartNum="AT94");