SC_AC16_10a
Shelly Cashman Access 2016 | Module 10: SAM Project 1a
Shelly Cashman Access 2016 | Module 10: SAM Project 1a
West Coast Outdoor Advertisers
USING SQL
GETTING STARTED
· Open the file SC_AC16_10a_FirstLastName_1.accdb, available for download from the SAM website.
· Save the file as SC_AC16_10a_FirstLastName_2.accdb by changing the “1” to a “2”.
· Hint: If you do not see the .accdb file extension in the Save As dialog box, do not type it. The program will add the file extension for you automatically.
· Open the _GradingInfoTable table and ensure that your first and last name is displayed as the first record in the table. If the table does not contain your name, delete the file and download a new copy from the SAM website.
SPECIAL NOTE: SQL QUERIES
To ensure accurate grading in this project, use the conventions listed below when writing your SQL commands:
· Do not enclose field names and table names in square brackets [] when creating and modifying these SQL queries. All field names and table names consist of single words and do not require brackets.
· Use parentheses () in your SQL code only when specified.
· All SQL commands should end with a semicolon (;).
· Only modify the aspects of the SQL commands that are specified in the assignment steps.
PROJECT STEPS
Create a new query in SQL View based on the States table with the following requirements:
a. Add all fields from the States table to the new query using the asterisk (*) in the Select clause.
b. Be sure to end the SQL command with a semicolon (;).
c. Run the query to produce the results shown in Figure 1 on the next page.
d. Save the query as StatesQuery, and then close the query.
Figure 1: StatesQuery Results
Open the AdRepQuery in SQL View, and then add the LastName field to the SELECT clause (after the FirstName field). Run the query, and ensure that the results match those shown in Figure 2 below Save and close the AdRepQuery.
Figure 2: AdRepQuery Results
Open the RentalTotalsQuery in SQL View. Add a computed field to the SELECT clause (after the Months field) as described below:
e. The computed field should calculate the total cost for the billboard rental by multiplying the Cost field value by the Months field value. (Hint: Enter Cost * Months as the computation.)
f. Use TotalCost as the name(alias) for this computed field. (Hint: Use the AS clause.)
g. Run the query, and ensure that the results match those shown in Figure 3 below. (Hint: Your records may be in a different order.The last row is not displayed in the figure.) Save and close the RentalTotalsQuery.
Figure 3: Portion of RentalTotalsQuery Results
Open the RentalsCriteriaQuery in SQL View. Add a WHERE clause to the query in the position shown in Figure 4 below that restricts retrieval to only those rentals where the cost is greater than 800. (Hint: Figure 4 demonstrates the proper location for the WHERE clause, but it does not show the criteria that should be included in the WHERE clause.) Run the query, and check your results. Save and close the RentalsCriteriaQuery.
Figure 4: RentalsCriteriaQuery in SQL View
Open the BillboardTypesQuery in SQL View. Add an OR clause to the WHERE clause in the query so that the query retrieves only those records in which the Type field is equal to Digital or Poster. (Hint: Currently, the query only retrieves records where the Type field is equal to Digital.) Run the query, and ensure that the results match those shown in Figure 5. Save and close the BillboardTypesQuery.
Figure 5: BillboardTypesQuery Results
Open the AdRepStateQuery in SQL View. Add an AND clause to the WHERE clause in the query so that the query retrieves only those records in which the State field is equal to OR and the City field is equal to Portland. (Hint: Currently, the query only retrieves records in which the State field is equal to OR.) Run the query, and ensure that the results match those shown in Figure 6. Save and close the AdRepStateQuery.
Figure 6: AdRepStateQuery Results
Open the OregonCountQuery in SQL View. Modify the SELECT clause to count the number of billboards that are located in OR. (Hint: Change the SELECT clause to COUNT(BillboardID)). Use the AS clause to set the alias of the function result to StateCount. Run the query and ensure that the results match those shown in Figure 7 below. Save and close the OregonCountQuery.
Figure 7: OregonCountQuery Results
Open the JoinQuery in SQL view. Add a WHERE clause that joins the Billboard table and the States table. The common field in both tables is State. You will need to qualify the State field in the WHERE clause. Run the query, and ensure that the results match those shown in Figure 8. (Hint: All rows are not displayed in the figure. The order of the records may differ. There should be 37 records in the result.) Save and close the JoinQuery.
Figure 8: Portion of the JoinQuery Results
Figure 9: Portion of the BillboardCirculationQuery Results
Open the SortQuery in SQL View. Modify the query to sort the records in ascending order by the State field. (Hint: Use the ORDER BY clause.) Run the query, and ensure that the results match those shown in Figure 10 below. Save and close the SortQuery.
Figure 10: SortQuery Results
Open the GroupingQuery in SQL View. Modify the query by completing the following tasks:
h. Add the State field to the SELECT statement. The State field should appear before the COUNT(BillboardID) function.
i. Group the records by the State field.
j. Sort the records by the State field in Ascending order.
Run the query, and ensure that the results match those shown in Figure 11 below. Save and close the GroupingQuery.
Figure 11: GroupingQuery Results
Open the AdRepSortQuery in SQL View. Modify the query to sort the records first in descending order by the State field, and then in ascending order by the City field. (Hint: Use the ORDER BY clause.) Run the query, and ensure that the results match those shown in Figure 12 on the next page. Save and close the AdRepSortQuery.
Figure 12: AdRepSortQuery Results
Save and close any open objects in your database. Compact and repair your database, close it, and then exit Access. Follow the directions on the SAM website to submit your completed project.
|
2 |