Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Trending in AI
Hot
Agentic AI EngineerForward-Deployed EngineerGenAI EngineerAI Architect
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
ExperiencesCoaching
New
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
Start free
Classify Q1 2025 Metric Measurements
00:00
5 left

Classify Q1 2025 Metric Measurements

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

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the two tables are in the Question tab.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.