Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Profile Incomplete Customer Records

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Profile Incomplete Customer Records. Start with the requirements and the one table on the right.

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.

Problem

You are given a customer profile table from Best Buy account data. Some records are incomplete or inconsistent: email may be missing, phone may be blank, city may be null, and loyalty tier values may not follow the expected standard. Write a PostgreSQL query that returns one row per customer_id with a data_quality_status of Complete, Incomplete, or Inconsistent. Treat a record as Incomplete if email, phone, or city is null or an empty string. Treat a record as Inconsistent if loyalty_tier is not one of My Best Buy, My Best Buy Plus, or My Best Buy Total. If both issues exist, label the record as Inconsistent. Return the results ordered by customer_id.

Schema

customer_profiles
ColumnTypeDescription
customer_idPKINTUnique customer identifier
full_nameVARCHAR(100)Customer full name
emailVARCHAR(150)Customer email address
phoneVARCHAR(20)Customer phone number
cityVARCHAR(100)Customer city
loyalty_tierVARCHAR(50)Best Buy loyalty membership tier
Tablescustomer_profiles
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results