/* Entries in Transactions Table */ SELECT * FROM Transactions WHERE ParentForm = 'Day Process' AND EntryDate >= '20180401' AND ( AccountNo IN (SELECT AccountNo FROM Accounts WHERE (InterestPaymentType = 'Quarterly' OR InterestPaymentType = 'Half Yearly' OR InterestPaymentType = 'Yearly')) OR AccountNo_From IN (SELECT AccountNo FROM Accounts WHERE (InterestPaymentType = 'Quarterly' OR InterestPaymentType = 'Half Yearly' OR InterestPaymentType = 'Yearly')) OR AccountNo_To IN (SELECT AccountNo FROM Accounts WHERE (InterestPaymentType = 'Quarterly' OR InterestPaymentType = 'Half Yearly' OR InterestPaymentType = 'Yearly')) OR AccountNo IN (SELECT SBAccountNo_Interest FROM Accounts WHERE (InterestPaymentType = 'Quarterly' OR InterestPaymentType = 'Half Yearly' OR InterestPaymentType = 'Yearly')) ) ORDER BY ID GO /* Entries in Accounts Interest Details Table */ SELECT * FROM Accounts_Interest_Details WHERE IsUsed = 1 AND InterestDate >= '20180401' AND AccountNo IN (SELECT AccountNo FROM Accounts WHERE (InterestPaymentType = 'Quarterly' OR InterestPaymentType = 'Half Yearly' OR InterestPaymentType = 'Yearly')) ORDER BY InterestDate, AccountNo GO =========After Confirmation========================== DELETE FROM Transactions WHERE ParentForm = 'Day Process' AND EntryDate >= '20180401' AND ( AccountNo IN (SELECT AccountNo FROM Accounts WHERE (InterestPaymentType = 'Quarterly' OR InterestPaymentType = 'Half Yearly' OR InterestPaymentType = 'Yearly')) OR AccountNo_From IN (SELECT AccountNo FROM Accounts WHERE (InterestPaymentType = 'Quarterly' OR InterestPaymentType = 'Half Yearly' OR InterestPaymentType = 'Yearly')) OR AccountNo_To IN (SELECT AccountNo FROM Accounts WHERE (InterestPaymentType = 'Quarterly' OR InterestPaymentType = 'Half Yearly' OR InterestPaymentType = 'Yearly')) OR AccountNo IN (SELECT SBAccountNo_Interest FROM Accounts WHERE (InterestPaymentType = 'Quarterly' OR InterestPaymentType = 'Half Yearly' OR InterestPaymentType = 'Yearly')) ) GO UPDATE Accounts_Interest_Details SET IsUsed = 0 WHERE IsUsed = 1 AND InterestDate >= '20180401' AND AccountNo IN (SELECT AccountNo FROM Accounts WHERE (InterestPaymentType = 'Quarterly' OR InterestPaymentType = 'Half Yearly' OR InterestPaymentType = 'Yearly')) GO