How do you approach data cleaning and preprocessing in your analysis?
Write a PostgreSQL query that standardizes the available lead fields, excludes unusable records, keeps the latest valid record for each normalized email, and adds campaign names when available. Rows with a NULL or invalid signup_date must be ignored.
email, source, campaign_code, campaign_name, and signup_date.Unattributed when no campaign matches.signup_date ascending, then email ascending.| Column | Type | Description |
|---|---|---|
| lead_idPK | INTEGER | Unique raw lead identifier |
| VARCHAR(150) | Raw lead email address | |
| source | VARCHAR(80) | Raw acquisition source |
| campaign_code | VARCHAR(40) | Raw campaign identifier |
| signup_date | VARCHAR(10) | Raw signup date text in expected YYYY-MM-DD format |
| Column | Type | Description |
|---|---|---|
| campaign_codePK | VARCHAR(40) | Campaign identifier |
| campaign_name | VARCHAR(150) | Readable campaign name |