Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
In this course, author Adam Wilbert illustrates how to create and leverage real-world queries and turn raw data into usable information. The course covers setting up queries, performing calculations, using the built-in Access functions to further refine query results, and identifying top performers or areas for improvement based on a range of criteria.
As with many of the objects and controls that you'll encounter in Access, one of the easiest ways to construct a basic query is to use the Simple Query Wizard. The wizard will present a series of options to guide us through the creation process and will provide us with a good base that we can go back and tweak using all of the tools in the full design environment later. When constructing a query, whether you are using the wizard or the Design View, it's critical that we start with a clear and specific question that we want answered. So, before jumping in with a vague idea of the kind of information you're looking for, make sure that you can succinctly verbalize the question that you are going to ask.
The more you can visualize the question beforehand and think about all of the pieces that you will need to gather to get the right answers, the easier the build process will be. In this movie, we are going to use the Wizard to walk us through the steps to create a query which will answer the following question. What are our customer's email addresses? Let's go into Access and use the wizard to answer this question. I will go up to the Create tab and in the Query section, I will choose Query Wizard. We will choose this Simple Query Wizard and say OK. The Simple Query Wizard is broken up into three parts.
We have a drop-down menu where we can select all of the tables and queries that are in our database. Let's go ahead and select our DirectCustomers table. The other two fields are Available Fields and Selected Fields. Available Fields lists all of the fields that are in our table. Selected Fields are all of the fields that will be used to construct the query. Let's go-ahead and move FirstName and LastName over to Selected Fields using the single arrow. If I accidentally grab a field I don't need, for instance Phone number, you can use the back arrow to move it back.
Let's also grab Email address. Go ahead and say Next and Access will ask us for a file name. The default file name is based off of the table that we originally selected for our query. We will go ahead and highlight this and name this query qry_email. We will take a look at the query design view in a future movie, so for now just go ahead and open the query to view the information. This is the record set that the query returns. We have got our FirstName, LastName, and Email addresses from our DirectCustomers table.
Let's use the Query Wizard to build a second query. The question we want to ask this time is, who are our best customers? For this query, we will need information from the Customers table as well some information about their orders. Let's go back into Access. Once again, we will go up to the Create tab and the Query Wizard. We will do another Simple Query Wizard and say OK. We will select the DirectCustomers table, so let's scroll up to find DirectCustomers and from there again we will add FirstName and the LastName. Then we will need some information about the price of the products that they ordered.
Let's go into the Products table and select Price. We will move that one and add it to our query. Go ahead and say Next. This time we are presented with another window that we didn't see the first time around. Because price includes numerical data, Access asks us if we want to do anything specific with that data. We can just show the details, which is the default view, or we can actually apply some summary calculations. Let's take a look at the calculations that we can use. Click on the Summary radio button and then choose Summary Options. For our Price field, we can choose to sum the prices. Basically add all of the transactions together.
We can find the average transaction price, the minimum, or the maximum. Now, the question that we asked was who was our best customer and this is going to depend a little bit on how you define best. Is our best customer the customer that spent the most amount of money or is our best customer is the customer that might have the highest average transaction? There are a couple of ways that we can interpret that question. So, let's just go ahead and choose Sum and Avg and let's also turn on Count records so we can get a total count for the number of orders that each customer has placed.
We will go ahead and say OK and then Next. We will give this new query a name. We will call this qry_ OurBestCustomers and then we will select Finish. Now, I am going to go ahead and expand these rows a little bit so we can see the full calculated total. And I am just going to drag on the bar between these column row. So, this query records that gives us the FirstName, LastName, a total for all of the transactions that they have spend with us, the average transaction price, and the number of transactions for each customer.
We can now sort these columns from high to low. For instance, if I click on this drop- down menu, I can say Sort Largest to Smallest on Sum Of Price and we will see that Sebastian Rich has spent the most money overall with our company. If we were to sort by Avg Of Price, we can say Largest to Smallest, and we will see that these three customers have all spent the same average. But we can also see that they've only had one transaction. Let's go ahead and sort the Count column. Largest to Smallest and we will see that this person has had nine transactions with our company.
So, depending on how you define best customer, we have got three different answers. The Query Wizard provides a quick and easy way to get started writing queries. You can combine fields from multiple tables and even apply some basic aggregate calculations to your data. The Simple Query Wizard walks you through the build process step by step and can provide you with a solid base on which you can add on more advanced functionality in the query design environment. By starting with a query written in the wizard, we can begin to see how some of the choices we made in the dialog boxes translate into the written query.
We will take a look at that in the next movie.
There are currently no FAQs about Access 2010: Queries in Depth.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.