Вы находитесь на странице: 1из 4

Chapter 2 Questions:

While using the MS Access DB, How do you:


1. Include a field in an Access query?
Include the field in the design grid and make sure the fields Show check box contains a check mark.
2. Create a computed field in an Access query
Type the formula instead of a field name in the design grid. Alternatively, you can type the formula in the Zoom dialog box.
3. How do you join tables in an Access query
Include field lists from both tables in the query. Provided they have matching fields, a join line will connect the tables. Include the
desired fields from either table in the design grid.
4. What is the purpose of the select statement
The Select command within relational algebra takes a horizontal subset of a table; that is, it retrieves certain rows from an existing
table and saves them as a new table

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

BookCode and AuthorNum

Inventory

BookCode and BranchNum.

Regarding the Premiere Products database:


6. List the number and name of all customers represented by sales rep 20.

CustomerNum
CustomerName
148
Al's Appliance and Sport
524
Kline's
842
All Season

SELECT CustomerNum, CustomerName


FROM Customer
WHERE RepNum="20";

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

SELECT CustomerNum, CustomerName


FROM Customer
WHERE ([RepNum]="65") AND
([CreditLimit]=10000);

8. How many customers have a credit limit of $7,500?


SELECT Count(CustomerNum) AS
CustCount
FROM Customer
WHERE (CreditLimit=7500);

CustCount
4

9. Find the total of the balances for all customers represented by sales rep 35.

SumOfBalance
$8,815.75

SELECT Sum(Balance) AS SumOfBalance


FROM Customer
WHERE (RepNum="35");

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

SELECT Part.Class, Sum([OnHand]*[Price]) AS


[Value]
FROM Part
GROUP BY Part.Class;

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.

4. What is a subquery? When is a subquery executed?


A subquery is a query that is included in another query. The subquery is evaluated before the query that contains it.

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.

SELECT Customer.CustomerNum, Customer.CustomerName


FROM Rep INNER JOIN Customer ON Rep.RepNum = Customer.RepNum
WHERE (((Rep.LastName)="Hull") AND ((Rep.FirstName)="Richard"));

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");

Вам также может понравиться