How to Return One Record Per Customer with Lowest Priority in Access
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.

- 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.
Verify your exact table name and the specific column names used for the customer identifier and priority ranking before writing your SQL syntax.
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.
Open your Access database, navigate to the 'Create' tab on the ribbon, and click 'Query Design'.
Close the 'Show Table' pop-up dialog. Right-click the query tab or use the top-left View menu to switch to 'SQL View'.
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;
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 Two Separate Queries in Design View
If you prefer the visual Query Designer over writing SQL, you can create a summary query first and then join it to your main table in a second query.
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. Open Your Data File: Export your table to Excel format and open it seamlessly in WPS Spreadsheet.
- 2. Insert a PivotTable: Select your entire data range, navigate to the 'Insert' tab, and click 'PivotTable'.
- 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'.

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'.




