ACC2: How to Determine a Percentage from a Column of ValuesID: Q132142
|
This article demonstrates how you can create three totals queries to
calculate a percentage for each unique record in a column of information,
and then shows you the results of running the queries. This example uses
the Orders table from the sample database NWIND.MDB to determine the
percentage of times an individual shipper was used for delivering invoice
orders.
To calculate a percentage for each unique record in a column of
information, follow these steps.
CAUTION: Following the steps in this example will modify the sample
database NWIND.MDB. Before testing the following example, you may want to
back up the NWIND.MDB file, or perform these steps on a copy of the NWIND
database.
Query Name: ShipperCounts
-------------------------------
Type: Select Query
Field: [Ship Via]
Table: Orders
Total: Group By
Sort: Ascending
Field: ShipperCount: [Ship Via]
Table: Orders
Total: Count
Query: ShipperTotalCount
----------------------------
Type: Select Query
Field: TotalCount: [Ship Via]
Table: Orders
Total: Count
Query: ShipperPercentage
------------------------
Type: Select Query
Join: None
Field: [Ship Via]
Table: ShipperCounts
Field: [Company Name]
Table: Shippers
Field: ShipperPercent: Format([ShipperCount]/[TotalCount],"Percent")
Ship Via Company Name ShipperPercent
--------------------------------------------
1 Speedy Express 29.68%
2 United Package 39.42%
3 Federal Shipping 30.89%
Microsoft Access "User's Guide," version 2.0, Chapter 11, "Designing
Select Queries," page 246
For more information about expressions in queries, search for
"expressions: in queries/filters," and then "Expressions in Queries
and Filters" using the Microsoft Access Help menu.
Keywords : kbusage QryHowto
Version : 2.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: April 29, 1999