Monday, November 3, 2014

how to get customers overdue payment recovery in t-sql

Mmmhmm.


DDL: http://ift.tt/19vj7ZG a description of your data structures.


DML: http://ift.tt/1p9yYF5 a description of how the data set is used or altered


Example:



DECLARE @customers TABLE (customerID INT IDENTITY, customerName VARCHAR(30))
DECLARE @leases TABLE (leaseID INT IDENTITY, customerID INT, totalAmount NUMERIC(10,4), paymentAmount NUMERIC(10,4), termMonths INT, paymentHistory VARCHAR(12), firstpaymentDate DATE, nextPaymentDate DATE, finalPaymentDate DATE)

INSERT INTO @customers (customerName)
VALUES ('Tinkywinky'),('Dipsy'),('La La'),('Po')
INSERT INTO @leases (customerID, totalAmount, paymentAmount, termMonths, paymentHistory, firstpaymentDate, nextPaymentDate, finalPaymentDate)
VALUES (1, 10000, 833.34, 12, 'NNNNNNN00000', '2014-7-1', '2014-12-1', '2015-6-1'),(2, 15000, 1000, 15, 'N01200000000', '2014-1-1', '2014-12-1', '2015-3-1'),
(3, 24000, 1000, 24, '000000000000', '2013-1-1', '2013-1-1', '2015-12-1'),(4, 48000, 1000, 48, '000000000000', '2013-1-1', '2013-1-1', '2017-12-1')



No comments:

Post a Comment