Selecting most recent transaction

eddy

Registered User.
Local time
Today, 08:07
Joined
Nov 30, 2005
Messages
23
I have these fields
ID,InvoiceID,DateEntered,Description

What I need now is to show the most recent transaction per invoice and what was the description for it.

Doing this

SELECT InvoiceID, Max(DateEntered) AS MaxOfDate
FROM TableName
GROUP BY InvoiceID;

Works Perfect. The problem I have is when I display the Description field. As soon as I do that, I see all invoices and not just the most recent. Anyone know how to write this sql statement that will return the invoiceID, dateentered, and Description only for the most recent invoice in the system?
 
You'd want a second query that joined that query to the original table on those 2 fields. You can then return the description for that record.
 

Users who are viewing this thread

Back
Top Bottom