Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Clean CRM Data for Reporting

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

Welcome to the SQL screen.

The question is on your right: Clean CRM Data for Reporting. 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 preparing a report from Veeva CRM account and call activity data, but several fields are missing or inconsistent. Write a PostgreSQL query that returns one row per account for calls created in March 2024, showing the account name, territory name, a cleaned specialty, the number of completed calls, and a data quality flag.

Treat blank specialties and NULL specialties as missing and replace them with 'Unknown'. Treat specialty values case-insensitively so values like cardiology and Cardiology are standardized to Cardiology. If an account has no mapped territory, show 'Unassigned'. The data quality flag should be 'Needs Review' when either the specialty was missing/blank or the territory is missing; otherwise return 'Clean'.

Schema

accounts
ColumnTypeDescription
account_idPKINTPrimary key for the Veeva CRM account
account_nameVARCHAR(100)Account name
specialtyVARCHAR(50)Raw specialty value that may be missing or inconsistently formatted
territory_idINTAssigned territory identifier
territories
ColumnTypeDescription
territory_idPKINTPrimary key for the territory
territory_nameVARCHAR(100)Territory name
calls
ColumnTypeDescription
call_idPKINTPrimary key for the call record
account_idINTAccount associated with the call
call_dateDATEDate the call was created
statusVARCHAR(20)Call status
Tablesaccountsterritoriescalls
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results