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
Find Data Inconsistencies in SQL
00:00
5 left

Find Data Inconsistencies in SQL

HardSQL · PostgreSQL

Problem

Given a specific dataset, how would you identify logical inconsistencies or missing data points in SQL for PharmaACE?

Write a query against the supplied study visit and measurement data. Identify expected visits with missing actual records, dates outside the allowed seven-day window, non-completed statuses, missing measurements, or measurements without a non-null result.

Output

  1. One row per expected visit with an issue
  2. Columns: expected_visit_id, patient_id, expected_date, actual_visit_id, issue_type, and issue_detail
  3. Exclude records without issues and order by expected_date, then expected_visit_id

Schema

expected_visits
ColumnTypeDescription
expected_visit_idPKINTUnique identifier for an expected study visit
patient_idVARCHAR(20)Study patient identifier
expected_dateDATEPlanned visit date
actual_visits
ColumnTypeDescription
actual_visit_idPKINTUnique identifier for a recorded visit
expected_visit_idINTExpected visit associated with the recorded visit
visit_dateDATEDate on which the visit occurred
statusVARCHAR(20)Recorded visit status
visit_measurements
ColumnTypeDescription
measurement_idPKINTUnique identifier for a measurement
actual_visit_idINTRecorded visit associated with the measurement
measurement_nameVARCHAR(40)Name of the collected measurement
result_valueDECIMAL(8,2)Numeric measurement result
Tablesexpected_visitsactual_visitsvisit_measurements
Interviewer

Your question is Find Data Inconsistencies in SQL. 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.