select * from mwpax left outer join mwtrn on mwtrn."Entry Number" = mwpax."Payment Reference" where mwpax."Who Paid" is null and mwtrn."Transaction Type" in ('J','K','L','I','M','N','O') and mwtrn."Who Paid" is not null; update mwpax Set MWPAX."Who Paid" = MWTRN."Who Paid" from mwtrn where mwtrn."Entry Number" = mwpax."Payment Reference" and mwpax."Who Paid" is null and mwtrn."Transaction Type" in ('J','K','L','I','M','N','O') and mwtrn."Who Paid" is not null; update mwtrn set "Who Paid" = 'G' where mwtrn."Transaction Type" in ('J','K','L','M','N','O') and mwtrn."Who Paid" is null; update mwtrn set [Transaction Type] = [Type] From MWPRO Where mwtrn.[Procedure Code] = mwpro.[Code 1] and ([transaction type] is null or [transaction type] = ''); Delete From MWPAX Where [Charge Reference] not in (Select [Entry Number] From MWTRN Where [Transaction Type] >= 'A' and [Transaction Type] <= 'H'); Delete From MWPAX Where [Payment Reference] not in (Select [Entry Number] From MWTRN Where [Transaction Type] >= 'I' and [Transaction Type] <= 'Y'); Select * From MWPAX pax, MWTRN pay, MWTRN chg Where pay.[Entry Number] = pax.[Payment Reference] and chg.[Entry Number] = pax.[Charge Reference] and chg.[Chart Number] <> pay.[Chart Number] Select pay.[chart number], chg.[chart number], [payment reference], [charge reference] From MWPAX pax, MWTRN pay, MWTRN chg Where pay.[Entry Number] = pax.[Payment Reference] and chg.[Entry Number] = pax.[Charge Reference] and chg.[Chart Number] <> pay.[Chart Number] Select pay.[chart number] paychart, pay.[case number] paycase, chg.[chart number] chgchart, chg.[case number] chgcase From MWPAX pax, MWTRN pay, MWTRN chg Where pay.[Entry Number] = pax.[Payment Reference] and chg.[Entry Number] = pax.[Charge Reference] and chg.[Chart Number] <> pay.[Chart Number]