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
Diagnose Inconsistent Customer Report
00:00
5 left

Diagnose Inconsistent Customer Report

MediumSQL · PostgreSQL

Problem

A customer report in AbbVie Customer 360 suddenly looks inconsistent from one week to the next. You are asked to write a SQL query that surfaces the first places you would investigate: customers whose latest weekly snapshot has a different segment, a different active flag, or a different total interaction count than the prior snapshot. Return one row per customer for the most recent snapshot date, along with the prior snapshot date, the current and previous values, and a change_type label showing whether the inconsistency is driven by a segment change, status change, interaction count change, or no prior snapshot.

Use the latest two snapshots available for each customer. Include only customers whose latest snapshot exists in the data, and count interactions that occurred on or before each snapshot date.

Schema

customer_profiles
ColumnTypeDescription
customer_idPKINTUnique customer identifier
customer_nameVARCHAR(100)Customer full name
regionVARCHAR(50)Commercial region
customer_weekly_snapshot
ColumnTypeDescription
snapshot_idPKINTSnapshot row identifier
customer_idINTReferences customer_profiles.customer_id
snapshot_dateDATEWeekly snapshot date
segmentVARCHAR(50)Customer segment in AbbVie Customer 360
is_activeBOOLEANWhether the customer is marked active
customer_interactions
ColumnTypeDescription
interaction_idPKINTInteraction row identifier
customer_idINTReferences customer_profiles.customer_id
interaction_dateDATEDate of interaction
channelVARCHAR(50)Interaction channel
interaction_countINTNumber of interactions recorded
Tablescustomer_profilescustomer_weekly_snapshotcustomer_interactions
Interviewer

Your question is Diagnose Inconsistent Customer Report. 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.