In This SiteIn This SectionThe number one source for making your website sell!
|
Setting Criteria in Your Microsoft Access QueriesSo far, you've learned how to create queries that take advantage of multiple tables. The real power of queries becomes evident when you begin to add criteria to the tables so that you refine your views very precisely. In our first lesson, Getting Started with Queries, we touched on this topic when you typed London OR Seattle into the Criteria field for City. This limited the display to ONLY those individuals based in London OR Seattle. This represents the use of criteria in the very simplest form. The criteria you enter can help you to filter huge databases to pull out very unique records. There are several ways to set criteria in the query design window. The two main areas are through the Criteria field or though the Totals field. You can also set criteria using calculated fields. We'll look at this in our next lesson. Limiting Records Using the Criteria FieldIn the query design window, you will see a Criteria field beneath every field value. You can create either simple or very complex criteria. Here are some examples:
Using the Totals FieldIn your query design window, you should see a line labeled Totals between the Table and Sort row on the left of the Query Design screen. If you do not, then select View-Show Totals and it will make that row visible. Open the Northwind database and click on the queries tab. Select New and Design View. add the Customers, Orders, Order Details and Products tables to the query window. From the Orders table, drag the ShipCountry Field into the first column of the query design window. Next, drag the ProductName field from the Products table and finally, Quantity from the Order Details table. Your screen should look like the following:
You will notice that the Totals field automatically shows the term Group By. This means that it will show all records, essentially doing nothing. If you click within the Totals field, you will see a drop-down arrow appear. Click on the arrow and a variety of options are presented to you. You can see them in the following image:
The options include:
Let's select Sum in the Quantity field and switch to the preview window. This will change the name of the Quantity field to SumOfQuantity and will show the total amount of units ordered for each product within each country. It will look like the following:
In this case, a total of 20 units of Boston Crab Meat was shipped to Argentina. 20 units of Chef Anton's Gumbo Mix, 2 of C ôte de Blaye, etc.If you change the Total field to Count, it will show you how many orders were placed. If you select Max, you'll see the maximum amount ordered at one time. Save your query as qGroupBy. In our next lesson, you'll learn how to perform calculations in your queries. These tutorials are part of an upcoming training course called "FrontPage Magic - How To Create A Database Driven Website For Non-Programmers". Stay tuned for more details on this exciting new product. Send your tips to .
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||