PDA

View Full Version : SQL Statement trouble


lokiette
01-22-2001, 05:07 PM
In my database there are several records for a single transaction, each record being associated with a datetime. I need to return only the latest record for each transaction. I know this is fairly simple, I just can't seem to get it right. Any help would be great! Thanks!

Jacob
01-22-2001, 11:47 PM
Hi lokiette,

Can you please paste your query / a sample of the code you are using, so I can see what your doing currently?

Thanks,

lokiette
01-23-2001, 09:29 AM
Jacob, here is the actual SQL Query. What I need to do is for each TransactionId, I need to show the latest LastUpdate.

Thanks, Molli

SELECT
ACHTransaction.MerchantId, ACHTransaction.RecNum, ACHTransaction.LastUpdate, ACHTransaction.BankReturnCode, ACHTransaction.TranslatedReturnCode, ACHTransaction.CheckDate, ACHTransaction.TraceNumber, ACHTransaction.TransactionId,
StatusLookup.Status
FROM
ServiceBureau.dbo.ACHTransaction ACHTransaction, ServiceBureau.dbo.Merchant Merchant, ServiceBureau.dbo.StatusLookup StatusLookup
WHERE
ACHTransaction.MerchantID = Merchant.MerchantID AND ACHTransaction.Status = StatusLookup.StatusNum
ORDER BY
ACHTransaction.LastUpdate DESC

Jacob
01-23-2001, 11:09 PM
Hi lokiette,

Thanks for posting your query. Next question: What are you using to run this query? asp/php/vb/perl?

Judging by the code I would guess asp/vb, but want to make sure.

Regards,