Others

Microsoft Access LEFT JOIN: Return the Latest Transaction per Customer

Chanuka GeekiyanageChanuka Geekiyanage Nov 14, 2026 869 views

Question details

Return every customer and the highest transaction number associated with that customer.

Return the Latest Transaction per Customer with an Access LEFT JOIN
Product
Microsoft Access
Device & OS
not provided
Scenario
A customer table must be joined to transactions while returning only the highest transaction number for each customer.
Observed behavior
The desired result includes one row per customer, with a blank transaction number when the customer has no transactions.
Before you start

Check that tblCust.ID matches tblTrans.CustID and that TransNr identifies the latest transaction by its highest value. If your table or field names differ, substitute them in the query.

Solution 1Recommended

Join customers to a grouped transaction subquery

Use this query to find the maximum transaction number per customer while retaining customers without transactions.

The subquery groups transactions by CustID and calculates Max(TransNr). The LEFT JOIN then matches those results to every row in tblCust.

1
Open SQL View

Open the database in Microsoft Access, select Create > Query Design, and switch to SQL View.

2
Enter the query

Replace the SQL in the editor with: SELECT tblCust.CustName, Q.TransNr FROM tblCust LEFT JOIN (SELECT tblTrans.CustID, Max(tblTrans.TransNr) AS TransNr FROM tblTrans GROUP BY tblTrans.CustID) AS Q ON tblCust.ID = Q.CustID;

3
Run and check the results

Select Run on the query ribbon. Check that each customer appears with the highest transaction number, or a blank value if no transaction exists.

Join customers to a grouped transaction subquery
Highest number versus latest date: Max(TransNr) finds the highest transaction number, not necessarily the most recent transaction by date. Use a date-based approach if transaction numbers do not follow transaction order.
Free Microsoft Office alternative

Review customer and transaction data in WPS Spreadsheets

WPS Office is a free, lightweight alternative with a familiar interface for working with Office files. Open exported customer and transaction data in WPS Spreadsheets for review; it does not run Access database queries or replace the LEFT JOIN.

Review exported customer and transaction data in a spreadsheetOpen and edit Microsoft Excel formats, including XLSX and XLSUse a familiar spreadsheet interface for an easier transition from Microsoft OfficeWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does the query use a LEFT JOIN?

The LEFT JOIN keeps all rows from tblCust, including customers with no matching CustID in tblTrans. Their TransNr value is Null.

Does Max(TransNr) always return the most recent transaction?

Only if the highest transaction number represents the latest transaction. If recency depends on a transaction date, the query needs to use that date instead.

Can this query return other fields from the latest transaction?

The example returns only CustName and the maximum TransNr. To retrieve other transaction fields, join the grouped result back to tblTrans using both CustID and TransNr; handle ties if those fields do not uniquely identify a row.

Where do I paste the SQL in Access?

In the database, select Create > Query Design, switch to SQL View, and paste the query into the SQL editor. Select Run to view the results.