I have this query ti give me a running sum from my sales table.
This gives me:
RSMID, Amount, RunningAmount
37 55000 96000
37 41000 96000
38 20000 20000
I need to pull a user name from my RSM table and match on RSMID in the sales table.
I have tried doing stuff in the WHERE statement but come up with the info displayed incorrectly.
Any help would be great. Thanks.
Code:
SELECT A.RSMID, A.Amount, (SELECT Sum(B.Amount) FROM Sales B WHERE B.RSMID=A.RSMID ) As RunningAmount
FROM Sales A
This gives me:
RSMID, Amount, RunningAmount
37 55000 96000
37 41000 96000
38 20000 20000
I need to pull a user name from my RSM table and match on RSMID in the sales table.
I have tried doing stuff in the WHERE statement but come up with the info displayed incorrectly.
Any help would be great. Thanks.