logo
search
Others

Calculate Tardy Percentages by Professor Using Group By in Access

WPS EditorWPS Editor Oct 10, 2026 870 views

Question details

The user needs to calculate the percentage of tardy records for each professor using an aggregate query in Microsoft Access without causing errors.

How to Calculate Tardy Percentages by Professor in Access
Product
Microsoft Access
Device & OS
not provided
Scenario
Creating an aggregate SQL query to summarize Boolean conditions (tardy vs. on time) and calculate a percentage grouped by a specific text field.
Observed behavior
Adding the professor field without grouping it correctly results in an aggregate-function error, or the calculated totals do not add up properly.
Before you start

Verify that your table name is correct and that the 'Tardy' field contains consistent Boolean (Yes/No) or numeric data so the mathematical query evaluates it properly.

Solution 1Recommended

Use an SQL GROUP BY Clause for the Aggregate Query

Applying a GROUP BY clause ensures that non-aggregated fields (like Professor) are properly structured, which resolves aggregate-function errors and yields correct percentage totals.

In Microsoft Access SQL, any field included in your SELECT statement that isn't wrapped in a mathematical function (such as Sum or Count) must be explicitly listed in a GROUP BY clause.

Since Microsoft Access evaluates a Boolean 'True' as -1, you can use a negative Sum function against your condition to return a positive count of matching records. Dividing this by the total Count(*) provides your percentage.

1
Open Query Design

Open your Access database, navigate to the Create tab on the top ribbon, and select Query Design.

2
Switch to SQL View

Close the 'Show Table' dialog box if it appears. Right-click the query tab or use the View dropdown on the ribbon, and select SQL View.

3
Input the SQL Query

Type the following SQL statement into the editor: SELECT Professor, -Sum(Class.Tardy=1)/Count(*) AS [Tardy Percent] FROM Class GROUP BY Professor;

4
Execute the Query

Click the Run button (red exclamation mark) in the Query Design ribbon to execute the statement and review the grouped results.

Use an SQL GROUP BY Clause for the Aggregate Query
Formatting the Final Result: To display the decimal as a proper percentage, switch back to Design View, open the Property Sheet for the [Tardy Percent] column, and set the Format property to 'Percent'.
Free Microsoft Office alternative

Analyze and Group Data Seamlessly with WPS Office

While Microsoft Access requires SQL knowledge for database queries, you can perform similar data grouping and percentage calculations effortlessly using PivotTables in WPS Spreadsheet. It offers a free, lightweight, and highly compatible alternative for data analysis.

  1. 1. Export Access Data: Export your Microsoft Access table to an Excel format (.xlsx) and open the file in WPS Spreadsheet.
  2. 2. Insert a PivotTable: Highlight your entire data range, navigate to the Insert tab on the top ribbon, and click PivotTable.
  3. 3. Group and Calculate: Drag the 'Professor' field to the Rows area and the 'Tardy' field to the Values area. Change the Value Field Settings to display data as a '% of Grand Total'.
Fully compatible with Microsoft Excel (.xlsx, .xls) formats for seamless data migration.Analyze and group large datasets effortlessly using intuitive PivotTables without writing SQL.Lightweight software architecture that opens large files quickly even on older computers.Familiar user interface that requires no steep learning curve for Microsoft Office users.
microsoft office alternative - wps office

Frequently Asked Questions

Why do I get an aggregate-function error in Microsoft Access?

This error triggers when your SELECT statement includes a field that is not part of an aggregate function (like Sum, Count, or Avg) and is also missing from your GROUP BY clause. Ensure all standalone fields are properly grouped.

Why does Access use a negative Sum to count matching records?

In Microsoft Access, a Boolean 'True' condition is stored as -1, and 'False' is stored as 0. Wrapping the condition in a negative Sum (e.g., -Sum([Tardy]=1)) converts the resulting negative number into a positive count of records matching the condition.

Can I calculate percentages in the Access Query Design view instead of SQL?

Yes. In the Query Design view, click the 'Totals' button (Sigma icon) on the ribbon. Keep the 'Total' row for the Professor field as 'Group By'. In an empty column, type an expression like `Tardy Percent: -Sum([Tardy]=1)/Count(*)` and change its 'Total' row to 'Expression'.