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
Extract and Aggregate Metrics with SQL
00:00
5 left

Extract and Aggregate Metrics with SQL

MediumSQL · PostgreSQL

Problem

Describe how you would use database querying languages to extract and aggregate performance metrics from a data source.

Using the provided source metadata and performance records, write a query for measurements recorded from 2025-01-01 through 2025-03-31. Include only records whose status is success or failed, while retaining sources with no qualifying records.

Output

  1. One row per source, ordered by source_id ascending.
  2. Columns: source_id, source_name, source_type, completed_measurements, avg_response_ms, peak_response_ms, avg_throughput, and success_rate_pct.
  3. Return NULL metric values for sources without qualifying records.

Schema

sources
ColumnTypeDescription
source_idPKINTUnique identifier for the data source
source_nameVARCHAR(100)Display name of the data source
source_typeVARCHAR(50)Classification of the data source
performance_metrics
ColumnTypeDescription
metric_idPKINTUnique identifier for the performance measurement
source_idINTSource associated with the measurement
measured_atDATEDate on which the measurement was recorded
statusVARCHAR(20)Outcome of the measurement
response_msDECIMAL(10,2)Response time in milliseconds
throughputDECIMAL(10,2)Measured throughput value
Tablessourcesperformance_metrics
Interviewer

Your question is Extract and Aggregate Metrics with SQL. 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.