Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
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 feedbackSuccess 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
SQL for Compliance Extraction
00:00
5 left

SQL for Compliance Extraction

MediumSQL · PostgreSQL

Problem

ERM Digital stores environmental, health, safety, and regulatory obligations across client facilities. Write a PostgreSQL query that produces an operational extract of active compliance records requiring attention by June 30, 2025.

Requirements

  1. Return records with status Open or Overdue whose due date is on or before June 30, 2025, or whose due date is missing.
  2. Use a LEFT JOIN so records remain visible when their facility or facility attributes are missing.
  3. Replace missing facility names, regions, responsible people, and due dates with readable labels. Classify each record as Overdue, Due by cutoff, or Missing due date.
  4. Order records by due date ascending, placing records without due dates last.

Schema

compliance_records
ColumnTypeDescription
record_idPKINTUnique compliance record identifier
facility_idINTReferenced facility identifier
requirement_nameVARCHAR(120)Name of the compliance obligation
statusVARCHAR(20)Current compliance record status
due_dateDATERequired completion date
responsible_personVARCHAR(100)Assigned compliance owner
created_dateDATEDate the record was created
facilities
ColumnTypeDescription
facility_idPKINTUnique facility identifier
facility_nameVARCHAR(120)Facility display name
regionVARCHAR(60)Operating region
erm_site_codeVARCHAR(30)ERM Digital site code
Tablescompliance_recordsfacilities
Interviewer

Your question is SQL for Compliance Extraction. Start with the requirements and the two 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.