0% found this document useful (0 votes)
53 views7 pages

Access Tutorial Part 3-1

This document provides instructions for creating different types of queries in Microsoft Access, including select, aggregate, and criteria queries. It explains how to create a basic select query to count customers by state, add search criteria to limit results to a specific customer name, and use an aggregate query with a GROUP BY to count orders containing a particular product.

Uploaded by

wwooowwman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views7 pages

Access Tutorial Part 3-1

This document provides instructions for creating different types of queries in Microsoft Access, including select, aggregate, and criteria queries. It explains how to create a basic select query to count customers by state, add search criteria to limit results to a specific customer name, and use an aggregate query with a GROUP BY to count orders containing a particular product.

Uploaded by

wwooowwman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

INFO​ ​211​ ​PSB

Access​ ​Tutorial​ ​Part​ ​3


Querying​ ​your​ ​Data

To​ ​complete​ ​this​ ​lab,​ ​follow​ ​the​ ​steps​ ​outlined​ ​in​ ​the​ ​“Logging​ ​into​ ​Lynda.com”​ ​page​ ​in​ ​myClasses.​ ​Please​ ​watch​ ​the​ ​ ​Access​ ​2013
Essential​ ​Training​ ​with​ ​Adam​ ​Wilbert​ ​ ​and​ ​then,​ ​practice​ ​your​ ​Access​ ​skills​ ​to​ ​create​ ​a​ ​simple​ ​database.​ ​Follow​ ​the​ ​steps​ ​below​ ​to
complete.

SET​ ​UP:​​ ​As​ ​a​ ​starting​ ​point,​ ​you​ ​should​ ​have​ ​completed​ ​part​ ​1​ ​and​ ​2​ ​in​ ​completion.​ ​These​ ​steps​ ​will​ ​not​ ​work​ ​if​ ​your​ ​database​ ​is​ ​not
setup​ ​correctly.

CREATING​ ​A​ ​BASIC​ ​SELECT​ ​QUERY​:​ ​Queries​ ​are​ ​for​ ​asking​ ​questions​ ​of​ ​the​ ​data.​ ​The​ ​first​ ​query​ ​you​ ​will​ ​create​ ​is​ ​designed​ ​to​ ​answer
the​ ​question​ ​“​How​ ​many​ ​customers​ ​do​ ​you​ ​have​ ​in​ ​Delaware?​”​ ​ ​To​ ​answer​ ​this​ ​question,​ ​we​ ​will​ ​create​ ​a​ ​custom​ ​query,​ ​which​ ​pulls
copies​ ​of​ ​data​ ​that​ ​you​ ​specify​ ​from​ ​tables​ ​or​ ​other​ ​queries.​ ​ ​Later​ ​in​ ​this​ ​tutorial,​ ​I’ll​ ​show​ ​you​ ​a​ ​very​ ​efficient​ ​way​ ​to​ ​do​ ​this,​ ​but​ ​for
now,​ ​we​ ​will​ ​create​ ​a​ ​simple​ ​Select​ ​query,​ ​sort​ ​the​ ​records​ ​by​ ​state,​ ​and​ ​manually​ ​count​ ​the​ ​number​ ​of​ ​customers.

1. Click​ ​on​ ​the​ ​Create​ ​ribbon​ ​and​ ​then​ ​click​ ​on​ ​the​ ​Query​ ​Design​ ​button.

2. This​ ​will​ ​open​ ​a​ ​blank​ ​query,​ ​and​ ​launch​ ​the​ ​Show​ ​Table​ ​box,​ ​which​ ​lets​ ​you​ ​add
tables​ ​and​ ​other​ ​queries​ ​to​ ​your​ ​new​ ​query​ ​design.​ ​ ​Because​ ​the​ ​customer
location​ ​information​ ​is​ ​stored​ ​in​ ​the​ ​Customers​ ​table,​ ​select​ ​customers​ ​from​ ​the
list​ ​and​ ​click​ ​the​ ​Add​ ​button.​ ​ ​Now,​ ​click​ ​the​ ​Close​ ​button.

3. Your​ ​query​ ​design​ ​view​ ​should​ ​look​ ​as​ ​follows:

1
INFO​ ​211​ ​PSB

4. To​ ​get​ ​our​ ​answer,​ ​we​ ​need​ ​to​ ​specify​ ​the​ ​information​ ​that​ ​our​ ​query​ ​is​ ​to​ ​return​ ​from​ ​the​ ​Customers​ ​table.​ ​ ​Please​ ​note
that​ ​Select​ ​queries​ ​will​ ​NOT​ ​change​ ​or​ ​modify​ ​the​ ​data​ ​in​ ​your​ ​underlying​ ​table,​ ​these​ ​queries​ ​simply​ ​make​ ​copies​ ​of​ ​the
table​ ​data​ ​and​ ​manipulate​ ​the​ ​temporary,​ ​copied​ ​data.​ ​ ​For​ ​our​ ​first​ ​query,​ ​double​ ​click​ ​on​ ​the​ ​CustomerName​ ​field.​ ​ ​This
will​ ​then​ ​place​ ​that​ ​field​ ​in​ ​the​ ​first​ ​column​ ​at​ ​the​ ​bottom​ ​of​ ​your​ ​screen.​ ​ ​Now,​ ​double​ ​click​ ​on​ ​the​ ​State​ ​field​ ​to​ ​place​ ​it​ ​in
the​ ​second​ ​column​ ​below.​ ​ ​When​ ​you​ ​are​ ​finished,​ ​your​ ​design​ ​screen​ ​should​ ​look​ ​as​ ​follows:

5. Before​ ​running​ ​the​ ​query,​ ​we​ ​want​ ​to​ ​sort​ ​the​ ​results​ ​by​ ​state​ ​so​ ​that​ ​we​ ​can​ ​count
the​ ​number​ ​of​ ​Delaware​ ​customers.​ ​ ​To​ ​do​ ​this,​ ​click​ S​ ort​​ ​in​ ​the​ ​State​ ​column.​ ​This
will​ ​reveal​ ​a​ ​pull-down​ ​menu.​ ​ ​Click​ ​on​ ​the​ ​pull-down​ ​menu​ ​and​ ​select​ ​Ascending
from​ ​the​ ​menu.

6. click​ ​the​ ​Save​ ​button​ ​ ​and​ ​give​ ​your​ ​query​ ​the​ ​name​ q
​ 1Query​ ​then​ ​press​ ​OK

2
INFO​ ​211​ ​PSB
7. Now,​ ​let’s​ ​run​ ​the​ ​query​ ​by​ ​clicking​ ​on​ ​the​ ​Run​ ​button​ ​in​ ​the​ ​toolbar​ ​toward​ ​the​ ​top​ ​of​ ​your​ ​screen.

8. Your​ ​query​ ​should​ ​return​ ​two​ ​columns​ ​of​ ​data​ ​sorted​ ​in​ ​ascending​ ​alphabetical​ ​order​ ​by​ ​state​ ​name.​ ​ ​As
you​ ​can​ ​see,​ ​there​ ​is​ ​one​ ​(1)​ ​customer​ ​from​ ​Delaware,​ ​five​ ​(5)​ ​customers​ ​from​ ​Maryland,​ ​and​ ​three​ ​(3)​ ​customers​ ​from

Virginia.

9. Close​ ​and​ ​save​ ​your​ ​query​ ​if​ ​prompted.

CREATING​ ​SELECT​ ​QUERIES​ ​WITH​ ​SEARCH​ ​CRITERIA​:​ ​Suppose​ ​that​ ​you​ ​want​ ​to​ ​answer​ ​the​ ​following​ ​question:​ ​“Where​ ​are​ ​your
Giant​ ​customers​ ​located?”​​ ​ ​We​ ​could​ ​simply​ ​sort​ ​the​ ​results​ ​by​ ​Customer​ ​Name​ ​and​ ​count​ ​the​ ​number​ ​of​ ​Giant​ ​customers,​ ​but​ ​this
could​ ​take​ ​a​ ​very​ ​long​ ​time​ ​if​ ​we​ ​have​ ​a​ ​large​ ​database.​ ​ ​It​ ​turns​ ​out​ ​that​ ​Access​ ​has​ ​some​ ​very​ ​powerful​ ​query​ ​options​ ​that​ ​make​ ​it
possible​ ​to​ ​only​ ​return​ ​our​ ​Giant​ ​customers.​ ​ ​To​ ​do​ ​this,​ ​we​ ​will​ ​create​ ​a​ ​copy​ ​of​ ​our​ ​first​ ​query,​ ​and​ ​then​ ​modify​ ​it​ ​to​ ​answer​ ​this
question.

10. The​ ​first​ ​step​ ​is​ ​to​ ​make​ ​a​ ​copy​ ​of​ ​the​ ​first​ ​query.​ ​ ​Llocate​ ​q1Query​ ​on​ ​the​ ​left​ ​side​ ​of​ ​the
screen,​ ​left-click​ ​on​ ​the​ ​query,​ ​and​ ​click​ ​Copy​.

11. Lleft​ ​click​ ​again​ ​on​ ​q1Query​ ​and​ ​click​ ​on​ ​Paste​.​ ​ ​This​ ​will​ ​launch​ ​the​ ​Paste​ ​As​ ​dialog​ ​box.
Name​ ​the​ ​copy​ ​q2Query​​ ​and​ ​click​ ​OK.

3
INFO​ ​211​ ​PSB
12. Open​ ​q2Query​ ​and​ ​click​ ​on​ ​the​ ​Design​ ​View​ ​button​ ​in​ ​the​ ​upper​ ​left​ ​corner​ ​of​ ​the​ ​screen.​ ​This​ ​will​ ​launch​ ​q2Query​ ​in
Design​ ​View.​ ​ ​To​ ​limit​ ​our​ ​search​ ​results​ ​to​ ​only​ ​customers​ ​with​ ​the​ ​name
Giant​,​ ​click​ ​on​ ​the​ ​Criteria​ ​field​ ​below​ ​Customer​ ​Name​ ​and​ ​type​ ​in
“Giant”​ ​(in​ ​quotes)​ ​in​ ​the​ ​Criteria​ ​field.​ ​ ​Now​ ​save​ ​the​ ​query​ ​to​ ​update​ ​it.

13. Run​ ​your​ ​query.

14. Your​ ​q2Query​ ​results​ ​should​ ​look​ ​as​ ​follows:​ ​There​ ​are​ ​a​ ​total​ ​of​ ​three
Giant​ ​customers​ ​in​ ​the​ ​database​ ​(two​ ​in​ ​MD,​ ​and​ ​one​ ​in​ ​VA).

15. Close​ ​and​ ​save​ ​your​ ​query​ ​if​ ​prompted

CREATING​ ​AGGREGATE​ ​(GROUP​ ​BY)​ ​QUERIES:​ ​ ​If​ ​you​ ​have​ ​a​ ​lot​ ​of​ ​data​ ​and​ ​you​ ​want​ ​the​ ​database​ ​to​ ​do​ ​the​ ​counting​ ​for​ ​you,​ ​ ​you
need​ ​to​ ​create​ ​an​ ​Aggregate​ ​Query.​ ​ ​To​ ​demonstrate​ ​how​ ​to​ ​do​ ​this,​ ​let’s​ ​answer​ ​the​ ​question​ ​“H
​ ow​ ​many​ ​orders​ ​contain​ ​1L​ ​Clear
Pure​ ​water?​”

16. The​ ​first​ ​step​ ​is​ ​to​ ​create​ ​a​ ​blank​ ​query​ ​(follow​ ​the​ ​steps​ ​in​ ​Creating​ ​a​ ​Basic​ ​Select​ ​Query​ ​above).

17. Add​ ​the​ ​Products​ ​ ​table​ ​and​ ​the​ ​Sales​ ​Detail​ ​table​ ​by​ ​double​ ​clicking​ ​on​ ​both.​ ​Close​ ​the​ ​Show​ ​Table​ ​window.

18. Your​ ​screen​ ​should​ ​look​ ​like​ ​this:

19. Now,​ ​double​ ​click​ ​on​ ​Product​ ​Name​ ​from​ ​the​ ​Products​ ​table​ ​(this​ ​will​ ​place​ ​Product​ ​Name​ ​in​ ​the​ ​first​ ​column​ ​of​ ​the​ ​query).
Next,​ ​double​ ​click​ ​on​ ​Quantity​ ​from​ ​the​ ​Sales​ ​Detail​ ​table​ ​(this​ ​will​ ​place​ ​Quantity​ ​in​ ​the​ ​second​ ​column​ ​of​ ​the​ ​query).​ ​ ​Your

4
INFO​ ​211​ ​PSB
screen​ ​should​ ​now​ ​look​ ​as​ ​follows:

20. Since​ ​we​ ​want​ ​Access​ ​to​ ​aggregate​ ​(i.e.​ ​sum​ ​or​ ​count)​ ​the​ ​results,​ ​click​ ​the​ ​Totals​ ​button​ ​in​ ​the​ ​toolbar​ ​at​ ​the​ ​top​ ​of​ ​the
screen.​ ​ ​This​ ​will​ ​add​ ​a​ ​new​ ​row​ ​to​ ​our​ ​query​ ​called​ ​Total,​ ​with​ ​the​ ​words​ ​“Group​ ​by”​ ​added​ ​to​ ​each​ ​column​ ​in​ ​this​ ​new

row:

21. Click​ ​on​ ​“Group​ ​By”​ ​underneath​ ​Quantity​ ​and​ ​a​ ​pull-down​ ​menu​ ​will​ ​appear.​ ​ ​Select​ ​Count​​ ​from​ ​the​ ​menu.

22. In​ ​the​ ​Criteria​ ​field​ ​below​ ​Product​ ​Name,​ ​add​ ​“1L​ ​Clear​ ​Pure”​ ​(in​ ​quotes).

23. Your​ ​query​ ​should​ ​now​ ​look​ ​like​ ​this:

24. Now,​ ​save​ ​your​ ​query​ ​as​ ​q3Query​​ ​and​ ​run​ ​it.​ ​ ​Your​ ​results​ ​should​ ​look​ ​like​ ​this:

NOTE:​ ​based​ ​on​ ​the​ ​additions​ ​you​ ​made​ ​to​ ​your​ ​database,​ ​your​ ​number​ ​may​ ​be​ ​different!

25. ​ ​Close​ ​your​ ​query​ ​and​ ​save​ ​if​ ​prompted.

GROUPING:​ ​ ​Microsoft​ ​Access​ ​also​ ​allows​ ​you​ ​to​ ​group​ ​results​ ​by​ ​more​ ​than​ ​one​ ​field.​ ​ ​To​ ​do​ ​this,​ ​you​ ​simply​ ​designate​ ​more​ ​than
one​ ​“Group​ ​By”​ ​field.​ ​ ​For​ ​example,​ ​if​ ​you​ ​want​ ​Access​ ​to​ ​answer​ ​the​ ​question​ ​“W
​ hat​ ​are​ ​the​ ​costs​ ​of​ ​your​ ​products?​”​ ​you​ ​would​ ​do
the​ ​following.

5
INFO​ ​211​ ​PSB
26. First,​ ​create​ ​a​ ​blank​ ​query​ ​and​ ​add​ ​the​ ​Products​ ​table

27. Add​ ​the​ ​Product​ ​Name​ ​and​ ​Cost​ ​fields​ ​by​ ​double​ ​clicking

28. Click​ ​the​ ​Totals​ ​button​ ​in​ ​the​ ​toolbar​ ​at​ ​the​ ​top​ ​of​ ​the​ ​screen

29. Your​ ​query​ ​should​ ​look​ ​as​ ​like​ ​this:

30. Save​ ​the​ ​query​ ​as​ ​q4Query​​ ​and​ ​run​ ​it.​ ​ ​Your​ ​results​ ​should​ ​look​ ​as​ ​follows:

STOP!

You​ ​are​ ​finished​ ​querying​ ​your​ ​data!​ ​Before​ ​you​ ​move​ ​on​ ​to​ ​Part​ ​3,​ ​CLOSE​ ​Access​ ​and​ ​ ​SUBMIT​ ​this​ ​part​ ​ ​in​ ​myClasses.

​ ​Make​ ​sure​ ​you​ ​read​ ​the​ ​grading​ ​Rubric​ ​below.

6
INFO​ ​211​ ​PSB

Grading​ ​for​ ​this​ ​part​ ​is​ ​as​ ​follows:

Description​ ​of​ ​Requirement​ ​Part​ ​3 Points

q1Query:​ ​what​ ​customers​ ​do​ ​you​ ​have​ ​in​ ​DE 5

q2Query:​ ​where​ ​are​ ​your​ ​giant​ ​customers​ ​located? 5

q3Query:​ ​How​ ​many​ ​orders​ ​contain​ ​1L​ ​Clear​ ​Pure​ ​water? 5

q4Query:​ ​What​ ​are​ ​the​ ​costs​ ​of​ ​your​ ​products? 5

Total 20​ ​Points

You might also like