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

left outer join invoice_payments ip on bip.invoice_payment_id = ip.id
left outer join payments p on ip.payment_id = p.id
where coalesce(p.record_id, 'NULL') != coalesce(bip.payment_number, 'NULL')
;

select 'G6ai' as sanity_query_name;

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