Imported text often carries spaces or inconsistent case. TRIM removes leading and trailing spaces, and LOWER gives an email or country key a consistent case. Neither function repairs a misspelled address. Keep cleanup separate from validation.
A blank string is different from NULL. NULLIF(TRIM(raw_email), '') converts an empty or space-only value to NULL. Applying LOWER afterward preserves missing values, which makes email coverage counts useful again. If you replace missing emails with a label too early, COUNT(email) counts that label as an address.
The exercise table is a fresh contact import derived from Lumen's customers. It deliberately includes spaces, capitals, blanks and missing values. Build a clean key without changing the source, then use the clean fields in filters and groups. Keep customer_id as the record identifier; shared or absent contact details aren't safe primary keys.