CREATE TABLE #Table1 (New_ID INT IDENTITY (1,1) PRIMARY KEY,SalesInvoiceID
INT,InsttNo INT,PaymentDate DATE,New_Amount INT )
CREATE TABLE #Table2 (New_ID INT IDENTITY (1,1) PRIMARY KEY,Instt_ID INT,
SalesInvoiceID INT,InsttNo INT,DueDate DATE,PaymentDate DATE,Amount INT,Status
VARCHAR(20))
INSERT INTO #Table1 (SalesInvoiceID,InsttNo,PaymentDate,New_Amount) VALUES (30
,1,'2019-05-02','12000')
INSERT INTO #Table1 (SalesInvoiceID,InsttNo,PaymentDate,New_Amount) VALUES (30
,2,'2019-06-02','12000')
INSERT INTO #Table1 (SalesInvoiceID,InsttNo,PaymentDate,New_Amount) VALUES (30
,3,'2019-09-02','4000')
INSERT INTO #Table1 (SalesInvoiceID,InsttNo,PaymentDate,New_Amount) VALUES (30
,4,'2019-12-02','4000')
INSERT INTO #Table2
(Instt_ID,SalesInvoiceID,InsttNo,DueDate,PaymentDate,Amount,Status) VALUES
(51,30,1,'2019-05-02',NULL,0,'Up-Coming')
INSERT INTO #Table2
(Instt_ID,SalesInvoiceID,InsttNo,DueDate,PaymentDate,Amount,Status) VALUES
(52,30,2,'2019-06-02',NULL,0,'Up-Coming')
INSERT INTO #Table2
(Instt_ID,SalesInvoiceID,InsttNo,DueDate,PaymentDate,Amount,Status) VALUES
(53,30,3,'2019-07-02',NULL,0,'Up-Coming')
INSERT INTO #Table2
(Instt_ID,SalesInvoiceID,InsttNo,DueDate,PaymentDate,Amount,Status) VALUES
(54,30,4,'2019-08-02',NULL,0,'Up-Coming')
INSERT INTO #Table2
(Instt_ID,SalesInvoiceID,InsttNo,DueDate,PaymentDate,Amount,Status) VALUES
(55,30,5,'2019-09-02',NULL,0,'Up-Coming')
INSERT INTO #Table2
(Instt_ID,SalesInvoiceID,InsttNo,DueDate,PaymentDate,Amount,Status) VALUES
(56,30,6,'2019-10-02',NULL,0,'Up-Coming')
INSERT INTO #Table2
(Instt_ID,SalesInvoiceID,InsttNo,DueDate,PaymentDate,Amount,Status) VALUES
(57,30,7,'2019-11-02',NULL,0,'Up-Coming')
INSERT INTO #Table2
(Instt_ID,SalesInvoiceID,InsttNo,DueDate,PaymentDate,Amount,Status) VALUES
(58,30,8,'2019-12-02',NULL,0,'Up-Coming')
SELECT
T2.Instt_ID
,T1.SalesInvoiceID
,T1.InsttNo
,T1.PaymentDate DueDate
,T2.PaymentDate
,T2.Amount
,T2.Status
FROM #Table1 t1
INNER JOIN #Table2 T2 ON t1.New_ID = t2.New_ID
DROP TABLE #Table1,#Table2
