Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Normalize Customer Addresses by Region
00:00
5 left

Normalize Customer Addresses by Region

HardSQL · PostgreSQL

Problem

You are given raw customer addresses exported from a TELUS Digital support workflow. The data contains inconsistent province and country values such as mixed casing, abbreviations, punctuation, and missing region mappings. Write a PostgreSQL query that returns one row per address with a normalized province code and normalized country name, then classifies each record as normalized, needs_review, or invalid.

Use the lookup tables to match cleaned province and country values. If a province cannot be matched but the country is Canada or the United States, mark the row as needs_review. If the country itself cannot be matched, mark the row as invalid. Otherwise mark the row as normalized.

Schema

customer_addresses
ColumnTypeDescription
address_idPKINTAddress record ID
customer_nameVARCHAR(100)Customer name
street_addressVARCHAR(150)Raw street address
cityVARCHAR(100)City name
province_rawVARCHAR(50)Raw province or state value
country_rawVARCHAR(50)Raw country value
province_reference
ColumnTypeDescription
province_codePKVARCHAR(10)Standard province or state code
province_nameVARCHAR(100)Standard province or state name
country_codeVARCHAR(10)Country code for the province or state
country_reference
ColumnTypeDescription
country_codeVARCHAR(10)Standard country code
country_nameVARCHAR(100)Standard country name
country_aliasPKVARCHAR(100)Accepted raw alias for the country
Tablescustomer_addressesprovince_referencecountry_reference
Interviewer

Your question is Normalize Customer Addresses by Region. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.