Others

How to Return One Record Per Customer with Lowest Priority in Access

Rana GarciaRana Garcia Oct 9, 2026 868 views

Question details

The user needs to create an MS Access query that retrieves exactly one record per customer, specifically the one with the lowest priority value, while retaining all original fields such as OrderID.

How to Return One Record Per Customer with the Lowest Priority in Access
Product
Microsoft Access
Device & OS
not provided
Scenario
Filtering database records to extract the highest-priority (lowest numeric value) entry for each unique customer without losing the rest of the row's data.
Observed behavior
Using a standard GROUP BY query on the customer restricts the output and loses other row-level details, necessitating a self-join or subquery to retrieve the complete record.
Before you start

Verify your exact table name and the specific column names used for the customer identifier and priority ranking before writing your SQL syntax.

Solution 1Recommended

Use an SQL Subquery with INNER JOIN

Write a nested SQL query to first find the minimum priority per customer, then join it back to the original table to retrieve all associated fields.

This is the most efficient and robust method to retrieve the complete record. By using an INNER JOIN on a grouped subquery, you ensure all original fields, such as OrderID, are retained without triggering grouping errors.

1
Open Query Design

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

2
Switch to SQL View

Close the 'Show Table' pop-up dialog. Right-click the query tab or use the top-left View menu to switch to 'SQL View'.

3
Enter the SQL Code

Type the following SQL code: SELECT b.* FROM (SELECT Customer, MIN(Priority) AS MinPriority FROM YourTable GROUP BY Customer) AS a INNER JOIN YourTable AS b ON a.Customer = b.Customer AND a.MinPriority = b.Priority;

4
Run the Query

Replace 'YourTable', 'Customer', and 'Priority' with your actual database object names, then click the 'Run' (!) button in the Design ribbon to view your filtered records.

Use an SQL Subquery with INNER JOIN
Handling Tied Records: If multiple rows for a single customer share the exact same minimum priority, this query will return all tied rows. You may need to add a secondary tie-breaking condition (like MIN(OrderID)) if strictly one row per customer is required.
Free Microsoft Office alternative

Looking for a Lightweight Alternative for Your Data Tasks?

While Microsoft Access is built for complex relational databases, most everyday data tracking, filtering, and grouping tasks can be handled much more easily in a spreadsheet. WPS Spreadsheet offers an incredibly powerful, lightweight, and free alternative to manage your data without a steep learning curve.

  1. 1. Open Your Data File: Export your table to Excel format and open it seamlessly in WPS Spreadsheet.
  2. 2. Insert a PivotTable: Select your entire data range, navigate to the 'Insert' tab, and click 'PivotTable'.
  3. 3. Group Customers and Find Minimums: Drag the 'Customer' field to the Rows area and the 'Priority' field to the Values area. Right-click the Priority values, select 'Value Field Settings', and change the summary function to 'Min'.
Fully compatible with Microsoft Excel (.xlsx) formats for easy data migration and sharing.Advanced Pivot Table features to easily group customer data and find minimum priority values in clicks.Lightweight installation with a familiar, user-friendly tabbed interface that works flawlessly on older machines.Completely free suite including fully-featured Writer, Spreadsheet, Presentation, and PDF editing tools.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my Access query return multiple records for the same customer?

This happens when two or more records for a specific customer have the exact same minimum priority value. Because the INNER JOIN matches on that priority value, it pulls all tied records. To fix this, you must add a secondary condition, such as joining on a minimum OrderID, to break the tie.

Can I achieve this without using an INNER JOIN?

Yes, you can use a correlated subquery in the WHERE clause, for example: WHERE Priority = (SELECT MIN(Priority) FROM YourTable AS T2 WHERE T2.Customer = YourTable.Customer). However, this method can sometimes be slower on very large tables compared to the INNER JOIN method.

What if I want to extract the record with the highest priority value instead?

You can easily adapt the query by changing the MIN() function to MAX(). In SQL view, modify 'MIN(Priority)' to 'MAX(Priority)'. In the visual Query Designer, change the Total row under the Priority field from 'Min' to 'Max'.