ecannelora
Programmer
I have two simple tables:
tblSched
-sched date
-sched amt
tblPayments(received)
-pmt date
-pmt amt
let's say my data looks like this (this would be for one customer, by the way)
tblSched tblPayments
1/1/05 100 1/1/05 150
2/1/05 100 2/1/05 150
3/1/05 100
4/1/05 100
one could look at this and see the next scheduled payment would not be due until 4/1, because the amount received has exceeded the amount scheduled. The amount received is 300, and in the Schedule table, 300 gets you through 3/1/05, so there's no scheduled payment due until 4/1/05
Here's my starting point for the query:
this query doesn't really do the trick. It just gives me the next scheduled date that is greater than the system date and greater than the last payment date. I need it to return the next scheduled date where the amount received is greater than the scheduled amount. Can anybody help?
tblSched
-sched date
-sched amt
tblPayments(received)
-pmt date
-pmt amt
let's say my data looks like this (this would be for one customer, by the way)
tblSched tblPayments
1/1/05 100 1/1/05 150
2/1/05 100 2/1/05 150
3/1/05 100
4/1/05 100
one could look at this and see the next scheduled payment would not be due until 4/1, because the amount received has exceeded the amount scheduled. The amount received is 300, and in the Schedule table, 300 gets you through 3/1/05, so there's no scheduled payment due until 4/1/05
Here's my starting point for the query:
Code:
SELECT Max([PmtReceivedDate]) AS ["last pay date"], Sum([PmtAmtReceived]) AS ["amt paidl"], (SELECT Min([SchedDate])
FROM tblSched
WHERE [SchedDate]>= [PmtReceivedDate] and [SchedDate]>=Date() and [Customer]='xxxx') AS ["due date"]
FROM tblPayments
WHERE [customer]='xxxx';
this query doesn't really do the trick. It just gives me the next scheduled date that is greater than the system date and greater than the last payment date. I need it to return the next scheduled date where the amount received is greater than the scheduled amount. Can anybody help?