Hi there,
I'm am trying to solve an SQL problem and running into some difficulty. By no means an expert in SQL so hoping the wonderful brains here can help me solve this problem.
Suppose I had some data that looked liked this:
.. a basic table consisting of a customer's weekly payment due.
Now, I want to write a select query which will return all rows in this table as well as a new column called 'AmountPassedDue' which will summarize all AmountDue values for the previous weeks, i.e. where DueDate is less and PaymentDay is equal to the current row.
I have tried this using a sub-query, but I need to pass in DueDate and PaymentDay into the sub-query, and this doesn't seem possible.
Is it possible to achieve this with a nested sub-query or is there another way?
Any advice would be much appreciated!
Thanks.