Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Audit CRM Data Integrity by Team

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

Your question is Audit CRM Data Integrity by Team. Start with the requirements and the three tables 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 CRM records entered by multiple teams. Write a PostgreSQL query that returns each team’s total records, the number of records with data integrity issues, and the issue rate. Treat a record as problematic if it has a missing owner, a missing account, or a status that is not one of new, working, qualified, or closed.

Schema

crm_records
ColumnTypeDescription
record_idINTPrimary key for the CRM record
team_idINTTeam that entered or owns the record
owner_idINTAssigned user; may be NULL when ownership is missing
account_idINTLinked account; may be NULL when the record is incomplete
statusVARCHAR(20)Current CRM status value
created_atDATEDate the record was created
teams
ColumnTypeDescription
team_idINTPrimary key for the team
team_nameVARCHAR(100)Team name
users
ColumnTypeDescription
user_idINTPrimary key for the user
user_nameVARCHAR(100)User name
Tablescrm_recordsteamsusers
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results