Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Normalize Messy CRM Contact Data

MediumSQL · PostgreSQL00:00
I
Practice interviewer
Your interviewer
In session
I
Interviewer

Welcome to the SQL screen.

The question is on your right: Normalize Messy CRM Contact Data. Read through the requirements and the three tables first.

Run and submit your code as often as you need. You also have five interviewer messages this session - want to talk through your approach, or are you ready to start coding?

You need to log in / sign up to run or submit.

Problem

You are given a messy CRM with inconsistent data entry standards across contacts, accounts, and activity logs. Write a PostgreSQL query that returns one row per contact with standardized fields, a data quality status, and the most recent activity date. Treat blank strings as missing values, normalize email addresses to lowercase, and classify each contact as valid, needs_review, or invalid based on the available data.

Schema

contacts
ColumnTypeDescription
contact_idPKINTPrimary key for the contact
account_idINTForeign key to the related account
full_nameVARCHAR(255)Raw contact name entered in the CRM
emailVARCHAR(255)Raw email address with inconsistent casing or blanks
phoneVARCHAR(50)Raw phone number with inconsistent formatting
statusVARCHAR(50)User-entered CRM status
accounts
ColumnTypeDescription
account_idPKINTPrimary key for the account
account_nameVARCHAR(255)Account name
owner_teamVARCHAR(100)Owning team for the account
activities
ColumnTypeDescription
activity_idPKINTPrimary key for the activity
contact_idINTForeign key to the related contact
activity_dateDATEDate when the activity occurred
activity_typeVARCHAR(50)Type of activity logged
Tablescontactsaccountsactivities
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results