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 Performance Metrics
00:00
5 left

SQL for Performance Metrics

MediumSQL · PostgreSQL

Problem

Write a SQL query to retrieve specific performance metrics from a relational database. Use the metric_catalog and performance_measurements tables to retrieve active metric codes M001, M002, and M003 for the first quarter of 2025. Include metrics without a recorded measurement and classify each result based on its target value.

Output

  1. One row per selected metric measurement, plus one row for a selected metric with no measurement.
  2. Columns: metric_code, metric_name, measured_on, metric_value, and performance_status.
  3. Include only active selected metrics and measurements from 2025-01-01 through 2025-03-31. Sort by metric code, measurement date ascending with missing dates last, and measurement ID.

Schema

metric_catalog
ColumnTypeDescription
metric_codePKVARCHAR(10)Unique performance metric code
metric_nameVARCHAR(100)Display name of the metric
target_valueNUMERIC(10,2)Target value used for classification
is_activeBOOLEANWhether the metric definition is active
performance_measurements
ColumnTypeDescription
measurement_idPKINTUnique measurement identifier
metric_codeVARCHAR(10)Referenced metric code
measured_onDATEDate on which the metric was measured
metric_valueNUMERIC(10,2)Recorded metric value
source_systemVARCHAR(50)System that supplied the measurement
Tablesmetric_catalogperformance_measurements
Interviewer

Your question is SQL for Performance Metrics. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.