How To Get Last Payment And Amt Of All
Jun 20, 2007
This will get me what I need based on an entered client id, but what is I want it to return the last payment date and amt for all loans? I tried removing the two where clauses and it only returned the last payment entered but not for all loans.SELECT dbo.tblLoan.Client_ID, MAX(dbo.tblPayments.PaymentDate) AS [Last Pay Date], SUM(dbo.tblPayments.AmountPaid) AS [Last Pay Amt]
FROM dbo.tblLoan INNER JOIN
dbo.tblPayments ON dbo.tblLoan.Loan_ID = dbo.tblPayments.Loan_ID
WHERE (dbo.tblLoan.Client_ID = @Client_ID)
AND dbo.tblPayments.PaymentDate =
(
SELECT TOP 1 p.PaymentDate
FROM dbo.tblPayments p
INNER JOIN dbo.tblLoan l
ON l.Loan_ID = p.Loan_ID
WHERE l.Client_ID = @Client_ID
ORDER BY p.PaymentDate DESC
)
GROUP BY dbo.tblLoan.Client_ID
View 13 Replies
Jun 20, 2007
I need to get the clientid, last payment date, and last payment amount. I have tried using MAX but this does not work. Can anyone see what I'm doing wrong? I get all payments and all dates. I'm summing the payment amount incase they made two payments on the same day, not likely but...
SELECT dbo.tblLoan.Client_ID, MAX(dbo.tblPayments.PaymentDate) AS [Last Pay Date], SUM(dbo.tblPayments.AmountPaid) AS [Last Pay Amt]FROM dbo.tblLoan INNER JOIN dbo.tblPayments ON dbo.tblLoan.Loan_ID = dbo.tblPayments.Loan_IDGROUP BY dbo.tblLoan.Client_IDHAVING (dbo.tblLoan.Client_ID = @Client_ID)
View 3 Replies
View Related
Mar 2, 2007
I'm trying to learn how to handle a payment schedule for small loan payments. I have the following structure:
tblClient, ClientID
tblLoan, LoanID, ClientID
tblPayments, PayID, PayDate, PayAmt, LoanID
tblLoanPaymentSchedule, ScheduleID, LoanID, PayDueDate, PayDueAmt, ReminderPrintDate, ReminderSentDate, PaymentRecDate
I have a page that batches (holds) all the payments in a work table and I can post them to the correct loan record but I'm just not sure how I would ask a stored procedure to mark the tblLoanPaymentSchedule with the PaymentRecDate for each payment posted. The schedule is pregenerated so that a payment due reminder can be sent out.
I appreciate any suggestions,
View 1 Replies
View Related
Aug 21, 2007
I use the following sql in a view to return the last payment date and amount made by clients. What I need is a way to return the payment date and amount for the payment prior to the last one.
Any help is appreciated very much,
SELECT dbo.tblPaymentReceipts.Client_ID, dbo.tblPaymentReceipts.PaymentDate AS LastPayDate, SUM(dbo.tblPaymentReceipts.AmountPaid) AS LastPayAmtFROM dbo.tblPaymentReceipts INNER JOIN (SELECT Client_ID, MAX(PaymentDate) AS LastPayDate FROM dbo.tblPaymentReceipts AS tblPaymentReceipts_1 GROUP BY Client_ID) AS A ON dbo.tblPaymentReceipts.Client_ID = A.Client_ID AND dbo.tblPaymentReceipts.PaymentDate = A.LastPayDateGROUP BY dbo.tblPaymentReceipts.Client_ID, dbo.tblPaymentReceipts.PaymentDate
View 6 Replies
View Related
Nov 13, 2007
Hello All,
I have a problem concerning keeping track of a value within a query.
I have a table that tracks invoices recieved and payments made.
For each invoice number there may be multiple payments made against it.
I need something that will check and make sure that each invoice number has its payments equal to its received amount.
Any help would be greatly appreciated.
Thanks,
View 5 Replies
View Related
Oct 18, 2001
Hi,
I'm using SQL Server 7. I have two tables as follows:
Table Invoices:
CustNo
DocDate
Amount
Table Payments:
CustNo
DocDate
Amount
Can anyone think of a process to find the invoice with no payment for each customer? I need to do some kind of process of elimination; I suppose.
Any Suggestions?
Thanks,
Denise
View 3 Replies
View Related
Jul 20, 2005
Hi all,I have a problem trying to generate the u/m list of customer.I am trying to generate a list of customer whoes last commence date isjan 04 to current.It is part of a billing system which the customer come in and pay fortheir season parking in carpark. They can pay for various periodshortest being 1 week.so i will have customer paying for 1 week, 1 month, 2 months or even 1year. Everytime a customer come in to pay, a new line at the incvoicewill be generated.My DB structure is as followedCustomer Table-Cust_Acc_No ----> (Primary Key)-Customer Name-Customer AddressInvoiceCust_acc_no-- Link to customer tableInvoice_no -- primary keyinvoice detailsinvoice_no -- link to invoice tablecommence_dateexpiry_dateamount_paidif i do aselect * from customer a, invoice b, invoice_details cwhere a.cust_acc_no=b.cust_acc_no andb.invoice_no=c.invoice_no andc.commence_date>1/1/04it doesnt works as it will showjohn, 1/1/04 - 31/1/04john, 1/2/04 - 29/1/04i do not want repetitive customer number just the latest commencedate.can anyone help?thanks
View 1 Replies
View Related
Aug 27, 2015
We have retention policy , and pay at the time year completion , now policy change and it is converted from yearly to monthly and this with effect from April-15.
if calculate the pay system will generate the Arrear payment of the employee from the month of April onward but i already paid the retention amount for month for two month April and May which i need to deduct the same otherwise this will double amount .
View 2 Replies
View Related