CS&E 2111 PRE LAB 9 Download from MyITLab exploring_a03_grader_h2.accdb, exploring_a03_grader_h3.accdb, Research Papers Excel File.xlsx, Golf Club Excel File.xlsx YOU MUST DOWNLOAD YOUR STARTING FILES FROM YOUR MYITLAB SESSION AND SUBMIT YOUR COMPLETED STARTING FILES TO YOUR MYITLAB SESSION OR YOUR ENTIRE LAB WILL NOT BE ACCEPTED. . PART 1: RECREATE THE RESEARCH PAPERS DATABASE STRUCTURE In this lab you will now learn how to create more complex queries. 1. 2. 3. 4. Rename the file, exploring_a03_grader_h2 to Research Papers with Complex Queries. Delete all the Access objects from the database. The Navigation Pane should be empty. Recreate the Research papers database structure. (Don’t forget to set up the table relationships.) Populate the database by importing the file, Research Papers Excel File.xlsx. Table Name: Client Field Type Properties Fields: ClientID FirstName LastName Address City State ZipCode HomePhone Short Text Short Text Short Text Short Text Short Text Short Text Short Text Short Text Field Type 5 Characters long 25 Characters long 50 Characters long 60 Characters long 25 Characters long 2 Characters long 5 Characters long 10 Characters long Properties Short Text Currency Date Field Type 5 Characters long None Input Mask Properties 5 Characters long None 2 Characters long Input Mask Properties 2 Characters long 20 Characters long Table Name: Charges Fields: ClientID Amount ChargeDate Table Name: Payments Fields: ClientID Amount PaymentType PaymentDate Table Name: PaymentMethod Short Text Currency Short Text Date Field Type Fields: MethodID MethodType Short Text Short Text Primary Key Default Value Input Mask Input Mask Input Mask Primary Key 1 Summarizing Information in Queries The query shown below lists a record for each client payment. What if we want to summarize the payments and list each Client with a sum of all their payments combined instead of listing each individual payment? We would do this by creating a Summary query. 1. 2. 3. 4. Create a new query which includes the Client and Payments table. Add the ClientID, FirstName, and LastName fields to the grid Add the Amount field to the grid three times. Click the Totals Icon. Click on the Totals Icon Notice a new row called Total has been added to the QBE grid with the words Group By. This row is used only when you want to display summary information for records in the database. The phrase “Group By” is used to instruct Access to summarize the Group by fields. The ClientID, FirstName, and LastName fields will only be shown once for every record, so we will “Group by” these fields. We also want to sum the payments for each client, average the payments for each client, and count the number of payments made by each client. Therefore, we must instruct Access to sum the amount field, average the amount field, and also count the number of records based on the amount field. We do this by using the Group By option on the Total row. 2 5. Click on the arrow next to the Group By phrase underneath the Amount field and select the Sum option, click on the Group By phrase underneath the second Amount field and select the Avg option, and finally, click on the Group By phrase underneath the third Amount field and select the Count option. 1. Click on the arrow next to the Group By phrase 2. Click on the Sum selection 3. Change Group By to Avg 4. Change Group By to Count 6. Run the query. Don’t worry about the order of the records in this dynaset. Just make sure 7 records are displayed. Notice now that we have summarized each record from the payments table. In our previous query J7500, was listed three times in the query. This query shows the record only once, and then adds the three payment records to create a sum of all the payments made by J7500, as well as an average and count of all three payment records. There are now a three new virtual fields that have been created in this query called SumOfAmount, AvgOfAmount, and CountOfAmount. The new field name adds the words SumOf, AvgOf, and CountOf to the respective amount fields in the grid. These fields will exist as long as the query is saved and is not deleted. 7. Name the query, Payments Summary Query. 3 Now, you do this one! Write a query that summarizes by State the total amount of Charges made (Sum), and the number (count) of charges made. Show the State field, sum of the charges and count of the charges. Name the query, State Charges Summary Query. If your query is correct you will see the following dynaset. Don’t worry about the order of the records in this dynaset. Just make sure 3 records are displayed. Another Summary Query Example Now, let’s add a criterion and a calculated field to our Summary Query. Write a query to summarize by Last Name, all of the charges made after 5/1/2008. You will add a surcharge of 20% on to these charges. List the Last Name, First Name, Original Charge, and New Charge. Notice, when using a Group by on the grid, a criterion must use the WHERE keyword in the Total row, and a calculated field must use the EXPRESSION keyword in the Total row. Now, let’s try it. 1. 2. Create a new query which includes the Client and Charges table. Add the LastName, FirstName, Amount, and ChargeDate fields to the grid 3. Click on the Totals Icon. 4. Click on the arrow next to the Group by phrase and change it to Where 5. Type the following in the criteria row under ChargeDate a. > #5/1/2008# 6. Click on the arrow next to the Group by phrase and change it to Expression 7. Type in the following in the criteria row. b. New Charge:[SumOfAmount] * 1.2 8. Run the query. 9. If your query is correct, you will see the following dynaset. 10. Name the query, New Charges Summary Query. 4 Now, you do this one! Write a query that summarizes by Client the total amount of Payments (sum) made for all clients in Ohio. In addition, create a calculated field that gives each Client a 10% rebate on their payments. Show the Last Name, First Name, sum of the payments and the Rebate amount (named, Rebate). Name the query, Client Rebate Summary Query. If your query is correct you will see the following dynaset. Don’t worry about the order of the records in this dynaset. Just make sure 4 records are displayed. PART 2: QUERYING GOLF CLUB.ACCDB You will be working with the Golf Club Database. This database keeps track of the activities and membership information for an Exclusive Golf Club located here in Ohio. The database consists of the following tables: The Membership table is a list of all members’ personal information and their membership status. Each member is identified by a unique Member ID. The Status table lists the different possible membership status types available (Junior, Senior, or Regular) and the yearly dues associated with that status. Each status is identified by a unique Status ID. The Payments table lists payments made by the members. Each payment is uniquely identified by a PaymentID. The Charges table lists charges incurred by the members. Each charge is uniquely identified by a ChargeID. The Recruiting table is a listing of all newly recruited members, the date they joined, and the Member ID of the current member who recruited them. Each recruit is uniquely identified by a RecruitID. The Description table is a listing of the different types of charges a member can post to their account. Each description is uniquely identified by a DescriptionID. 5 1. 2. 3. 4. 5. Rename the file, exploring_a03_grader_h3 to Golf Club. Delete all the Access objects from the database. The Navigation Pane should be empty. Create the Golf database structure. (Don’t forget to set up the table relationships.) Populate the database by importing the file, Golf Club Excel File.xlsx. Import the tables in the following Order: a. b. c. d. e. f. Description Table Name: Member Field Type Properties Fields: MemberID FirstName LastName Address City State ZipCode HomePhone StatusID Short Text Short Text Short Text Short Text Short Text Short Text Short Text Short Text Short Text 10 Characters long 25 Characters long 50 Characters long 60 Characters long 25 Characters long 2 Characters long 5 Characters long 10 Characters long 5 Characters long Table Name: Charges Field Type Properties Fields: ChargeID MemberID DescriptionID Amount ChargeDate Short Text Short Text Short Text Currency Date 25 Characters long 10 characters long 10 Characters long None Input Mask Table Name: Payments Field Type Properties Fields: PaymentID MemberID Amount PaymentDate Short Text Short Text Currency Date 25 Characters long 10 Characters long None Input Mask Table Name: Status Field Type Properties Fields: StatusID Status MembershipFee Short Text Short Text Currency 5 Characters long 20 Characters long None Table Name: Recruits Field Type Properties Fields: RecruitID MemberID FirstName LastName JoinDate Short Text Short Text Short Text Short Text Date/Time 10 Characters long 10 Characters long 25 Characters long 50 Characters long Table Name: Description Field Type Properties Fields: DescriptionID ChargeDescription Short Text Short Text 10 Characters long 50 Characters long Status Membership Charges Payments Recruits Primary Key Input Mask Primary Key Input Mask Primary Key Input Mask Primary Key Primary Key Primary Key 6 Use the golf club.accdb file to complete the following queries. You will name the queries, Query 1, Query 2, etc. 1. Query 1: The golf club has decided to give a 20 % discount for every charge of more than $200. Write a query that calculates the Charge Discount and the New Charge amount (Name this field New Charge) List the Member ID, First Name, Last name, charge description, the discount amount, and the New Charge Amount. 2. Query 2: One of the office manager’s complaints is the large number of small transactions they currently process. The manager has asked you to compile a list by member (Last Name) which includes the total number of payments made between May and June of 2012 that are under $500 and the average value of these payments. List the member’s last name, the total number of payments under $500 and the average value of these payments. 3. Query 3: Some of the older members have complained that the regular and junior members do not support the recruiting efforts of the club. In order to look into the matter the membership director has asked you to create a list that includes the names of persons who have been recruited after April 1, 2012. List the recruit’s name, the first and last name of regular or junior member who recruited them and the date the recruit joined. 4. Query 4: In order to recognize the merits of members recruiting efforts, the financial director has decided to give each existing member a referral bonus of $10 for each new member they recruited. List the Member ID, the First and Last name of the existing member, the total number of new members he recruited, and the member’s referral bonus. The result should be sorted so the persons with the largest number of recruits are shown first. 5. Query 5: The business director is considering installing an 800 number for use by members outside of the 614 area code. He has asked you to provide him a count of the number of members outside of the 614 area code. The list should only include one record that lists the number of members whose phone numbers are outside of the 614 area code. Lab submissions 1. Research Papers with Complex Queries.accdb 2. Golf Club.accdb 7
© Copyright 2026 Paperzz