Sie sind auf Seite 1von 2

More Query Exercises

1. Start the Access Database program and open the Northwind Database. (Hint: if it is
installed it should be, click the Help menu, then click the Sample Database option.)

2. Make sure you are in the Queries Object list.

3. Create a new query in Design View. Choose to base the query on the Products table.
(Hint: double-click Products in the list)

4. Close the Show Table screen. You should be in Query Design View now.

5. From the Products table box in the top half of the screen, include the
PRODUCTNAME and UNITPRICE fields. (Hint: You can include fields by 1)
Double-clicking the field name 2) Dragging and dropping the desired field from the
table down to the Query Grid 3) Click in the Field row in the Query Grid and use the
drop-down list to choose the desired field)

6. In the Criteria row under UNITPRICE, type Between 20 and 30

7. Click the View button in the toolbar to switch to datasheet view. The results should
display all the products that cost between $20 and $30 (including 20 and 30).

8. Switch back to Design View and delete all the criteria in the grid.

9. Now, click in the Criteria row under PRODUCTNAME and type >=S*

10. Click the View button in the toolbar to switch to datasheet view. The results should
display all the products that start with the letters S through Z.

11. Switch back to Design View and delete all the criteria in the grid.

Working with Calculated Fields in Queries

1. In the Query Grid, click in the first blank column in the Field row (to the right of
UNITPRICE).

2. Type the following: NewPrice:[UnitPrice]*1.03

3. Click the View button in the toolbar to switch to datasheet view. You should see a
new, calculated field that displays all the existing unit prices increased by 3%.

4. Close the query without saving changes.

5. Create a new query in Design View. Choose to base the query on the Employees
table. (Hint: double-click Employees in the list)

6. Close the Show Table screen. You should be in Query Design View now.
7. Click in the first column in the Field row of the Query Grid.

8. Type the following: EmployeeName:[Firstname]& &[Lastname] (Be sure to


leave a space between the quotation marks!)

9. In addition to this calculated field you created, also include in the Query Grid the
following fields from the table: HIREDATE, CITY, and HOMEPHONE.

10. Click the View button in the toolbar to switch to datasheet view. You should see a
new calculated field called EmployeeName that combines the first name and last
name of each employee into a single field.

11. Switch back to Design View. Delete the calculated field but do not delete the column
itself. (Hint: Click in the calculated field and press either Backspace or Delete until
it has been cleared.)

12. Now type the following: EmployeeName:[Lastname]&, &[Firstname] (Be sure


to leave a space after the comma within the quotation marks.

13. Click the View button in the toolbar to switch to datasheet view. You should see
your calculated field called EmployeeName that combines the first name and last
name of each employee into a single field, but now it lists LastName first.

14. Close the query without saving changes.

15. Exit the Access database.

Das könnte Ihnen auch gefallen