G
Guest
Hey there
I have a query that does this:
TXID TransactionDate PRID PrevPRID UnitPrice UnitsOrdere RunTot
54762 18-Jul-05 1 1 $1.95 -1 34
54763 03-Aug-05 1 1 $1.95 -1 33
54764 03-Aug-05 1 1 $1.95 -2 31
54765 30-Nov-05 1 1 $1.95 -2 29
54766 31-Mar-05 2 1 $4.85 81 81
54767 15-Apr-05 2 2 $4.85 -1 109
54768 03-May-05 2 2 $4.85 -1 108
What I want is to reset the running total when the PRID changes so that it
should look like this:
TXID TransactionDate PRID PrevPRID UnitPrice UnitsOrdere RunTot
54762 18-Jul-05 1 1 $1.95 -1 34
54763 03-Aug-05 1 1 $1.95 -1 33
54764 03-Aug-05 1 1 $1.95 -2 31
54765 30-Nov-05 1 1 $1.95 -2 29
54766 31-Mar-05 2 1 $4.85 81 81
54767 15-Apr-05 2 2 $4.85 -1 80
54768 03-May-05 2 2 $4.85 -1 79
Here's the SQL for the query:
SELECT TXTemp.TransactionID AS TXID, TXTemp.TransactionDate,
TXTemp.ProductID AS PRID, DLookUp("[ProductID]","TXTemp","[TransactionID] = "
& [TransactionID]-1) AS PrevPRID, TXTemp.UnitPrice, TXTemp.UnitsOrdered,
IIf([PRID]<>[PrevPRID],[UnitsOrdered],DSum("UnitsOrdered","TXTemp","[TransactionID]<=" & [TXID])) AS RunTot
FROM TXTemp
ORDER BY TXTemp.TransactionID;
Thanx
IAJG
I have a query that does this:
TXID TransactionDate PRID PrevPRID UnitPrice UnitsOrdere RunTot
54762 18-Jul-05 1 1 $1.95 -1 34
54763 03-Aug-05 1 1 $1.95 -1 33
54764 03-Aug-05 1 1 $1.95 -2 31
54765 30-Nov-05 1 1 $1.95 -2 29
54766 31-Mar-05 2 1 $4.85 81 81
54767 15-Apr-05 2 2 $4.85 -1 109
54768 03-May-05 2 2 $4.85 -1 108
What I want is to reset the running total when the PRID changes so that it
should look like this:
TXID TransactionDate PRID PrevPRID UnitPrice UnitsOrdere RunTot
54762 18-Jul-05 1 1 $1.95 -1 34
54763 03-Aug-05 1 1 $1.95 -1 33
54764 03-Aug-05 1 1 $1.95 -2 31
54765 30-Nov-05 1 1 $1.95 -2 29
54766 31-Mar-05 2 1 $4.85 81 81
54767 15-Apr-05 2 2 $4.85 -1 80
54768 03-May-05 2 2 $4.85 -1 79
Here's the SQL for the query:
SELECT TXTemp.TransactionID AS TXID, TXTemp.TransactionDate,
TXTemp.ProductID AS PRID, DLookUp("[ProductID]","TXTemp","[TransactionID] = "
& [TransactionID]-1) AS PrevPRID, TXTemp.UnitPrice, TXTemp.UnitsOrdered,
IIf([PRID]<>[PrevPRID],[UnitsOrdered],DSum("UnitsOrdered","TXTemp","[TransactionID]<=" & [TXID])) AS RunTot
FROM TXTemp
ORDER BY TXTemp.TransactionID;
Thanx
IAJG