The CRM and the billing system each keep their own customer records, keyed by the same customer_id: crm_customers (customer_id, name, email) and billing_accounts (customer_id, email, plan). Either system can have customers the other lacks, and either can have a NULL email.
Return one row for every customer_id that appears in either system:
- •
status — 'both', 'crm_only' or 'billing_only' - •
email_match — for 'both' rows, TRUE when the two emails are the same and FALSE when they differ. Two NULL emails count as the same; a NULL on one side only is a difference. For one-sided rows email_match is NULL.
Columns: customer_id, status, email_match. Sort by customer_id.