 left outer join invoice_payments ip on bipc.invoice_payment_id = ip.id
 left outer join payments p on ip.payment_id = p.id
 where coalesce(p.record_id, 'NULL') != coalesce(bipc.payment_number, 'NULL')
+and bipc.invoice_payment_record_id!=0
 ;
 
 select 'H8' as sanity_query_name;

select distinct bip.account_record_id
from analytics_payment_purchases bip
left outer join invoice_payments ip on ip.id = bip.invoice_payment_id
where coalesce(ip.record_id, 'NULL') != coalesce(bip.invoice_payment_record_id, 'NULL')
or coalesce(ip.ID, 'NULL') != coalesce(bip.invoice_payment_id, 'NULL')
or coalesce(ip.invoice_id, 'NULL') != coalesce(bip.invoice_id, 'NULL')
or coalesce(ip.type, 'NULL') != coalesce(bip.invoice_payment_type, 'NULL')

or coalesce(ip.created_date, 'NULL') != coalesce(bipc.created_date, 'NULL')
or coalesce(ip.account_record_id, 'NULL') != coalesce(bipc.account_record_id, 'NULL')
or coalesce(ip.tenant_record_id, 'NULL') != coalesce(bipc.tenant_record_id, 'NULL')
or bipc.invoice_payment_type != 'CHARGED_BACK')
and bipc.invoice_payment_record_id!=0
;

select 'H2' as sanity_query_name;
