I have a similar code working for a different query but i cant get this one to match up. I'm trying to obtain the previous value for fields "GallonsReceived" and "GallonsIssued" but the code is literally giving me the value of the "...PriorValue" fields instead of the original, non-calculated fields. Please reference screenshot below.
SQL:
SELECT tblTransactions.TransactionDate, tblTransactions.AirlineCompanyLookup, tblTransactions.GallonsReceived, (SELECT TOP 1 Dupe.GallonsReceived
FROM tblTransactions AS Dupe
WHERE Dupe.AirlineCompanyLookup = tblTransactions.AirlineCompanyLookup
AND Dupe.TransactionDate < tblTransactions.TransactionDate) AS GallonsReceivedPriorValue, tblTransactions.GallonsIssued, (SELECT TOP 1 Dupe2.GallonsIssued
FROM tblTransactions AS Dupe2
WHERE Dupe2.AirlineCompanyLookup = tblTransactions.AirlineCompanyLookup
AND Dupe2.TransactionDate < tblTransactions.TransactionDate) AS GallonsIssuedPriorValue
FROM tblTransactions
ORDER BY tblTransactions.TransactionDate DESC , tblTransactions.AirlineCompanyLookup;